<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Rank2Types #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- | See &lt;https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst&gt;</span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Distribution.Backpack.UnifyM</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-5"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Unification monad</span></span><span>
</span><span id="line-6"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier">UnifyM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-7"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#runUnifyM"><span class="hs-identifier">runUnifyM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-8"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#failWith"><span class="hs-identifier">failWith</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-9"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier">addErr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-10"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#failIfErrs"><span class="hs-identifier">failIfErrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-11"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#tryM"><span class="hs-identifier">tryM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#addErrContext"><span class="hs-identifier">addErrContext</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#addErrContextM"><span class="hs-identifier">addErrContextM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier">liftST</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifEnv"><span class="hs-identifier">UnifEnv</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier">getUnifEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Modules and unit IDs</span></span><span>
</span><span id="line-20"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier">ModuleU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU%27"><span class="hs-identifier">ModuleU'</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModule"><span class="hs-identifier">convertModule</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleU"><span class="hs-identifier">convertModuleU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier">UnitIdU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU%27"><span class="hs-identifier">UnitIdU'</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitId"><span class="hs-identifier">convertUnitId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU"><span class="hs-identifier">convertUnitIdU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleSubstU"><span class="hs-identifier">ModuleSubstU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleSubstU"><span class="hs-identifier">convertModuleSubstU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleSubst"><span class="hs-identifier">convertModuleSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleScopeU"><span class="hs-identifier">ModuleScopeU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#emptyModuleScopeU"><span class="hs-identifier">emptyModuleScopeU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleScopeU"><span class="hs-identifier">convertModuleScopeU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleWithSourceU"><span class="hs-identifier">ModuleWithSourceU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertInclude"><span class="hs-identifier">convertInclude</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleProvides"><span class="hs-identifier">convertModuleProvides</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleProvidesU"><span class="hs-identifier">convertModuleProvidesU</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Compat.Prelude.html"><span class="hs-identifier">Distribution.Compat.Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Real.html#mod"><span class="hs-identifier">mod</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleShape.html"><span class="hs-identifier">Distribution.Backpack.ModuleShape</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html"><span class="hs-identifier">Distribution.Backpack.ModuleScope</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModSubst.html"><span class="hs-identifier">Distribution.Backpack.ModSubst</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Backpack.FullUnitId.html"><span class="hs-identifier">Distribution.Backpack.FullUnitId</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Backpack.html"><span class="hs-identifier">Distribution.Backpack</span></a></span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Distribution.Utils.UnionFind.html"><span class="hs-identifier">Distribution.Utils.UnionFind</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">UnionFind</span></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.ModuleName.html"><span class="hs-identifier">Distribution.ModuleName</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Package.html"><span class="hs-identifier">Distribution.Package</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.PackageDescription.html"><span class="hs-identifier">Distribution.PackageDescription</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Pretty.html"><span class="hs-identifier">Distribution.Pretty</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Types.IncludeRenaming.html"><span class="hs-identifier">Distribution.Types.IncludeRenaming</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Types.ComponentInclude.html"><span class="hs-identifier">Distribution.Types.ComponentInclude</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Types.AnnotatedId.html"><span class="hs-identifier">Distribution.Types.AnnotatedId</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html"><span class="hs-identifier">Distribution.Types.ModuleRenaming</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Verbosity.html"><span class="hs-identifier">Distribution.Verbosity</span></a></span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.STRef.html#"><span class="hs-identifier">Data.STRef</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Traversable.html#"><span class="hs-identifier">Data.Traversable</span></a></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.ST.html#"><span class="hs-identifier">Control.Monad.ST</span></a></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.html#"><span class="hs-identifier">Data.Map</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Map</span></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.html#"><span class="hs-identifier">Data.IntMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier">IntMap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntMap.html#"><span class="hs-identifier">Data.IntMap</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IntMap</span></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../pretty/src/Text.PrettyPrint.html#"><span class="hs-identifier">Text.PrettyPrint</span></a></span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-comment">-- TODO: more detailed trace output on high verbosity would probably</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- be appreciated by users debugging unification errors.  Collect</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- some good examples!</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-keyword">data</span><span> </span><span id="ErrMsg"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrMsg"><span class="hs-identifier hs-var">ErrMsg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ErrMsg"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrMsg"><span class="hs-identifier hs-var">ErrMsg</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-80"></span><span>        </span><span id="err_msg"><span class="annot"><span class="annottext">ErrMsg -&gt; Doc
</span><a href="Distribution.Backpack.UnifyM.html#err_msg"><span class="hs-identifier hs-var hs-var">err_msg</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#Doc"><span class="hs-identifier hs-type">Doc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-81"></span><span>        </span><span id="err_ctx"><span class="annot"><span class="annottext">ErrMsg -&gt; [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#err_ctx"><span class="hs-identifier hs-var hs-var">err_ctx</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#Doc"><span class="hs-identifier hs-type">Doc</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-82"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-83"></span><span class="hs-keyword">type</span><span> </span><span id="MsgDoc"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MsgDoc"><span class="hs-identifier hs-var">MsgDoc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#Doc"><span class="hs-identifier hs-type">Doc</span></a></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#renderErrMsg"><span class="hs-identifier hs-type">renderErrMsg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrMsg"><span class="hs-identifier hs-type">ErrMsg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span>
</span><span id="line-86"></span><span id="renderErrMsg"><span class="annot"><span class="annottext">renderErrMsg :: ErrMsg -&gt; Doc
</span><a href="Distribution.Backpack.UnifyM.html#renderErrMsg"><span class="hs-identifier hs-var hs-var">renderErrMsg</span></a></span></span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrMsg"><span class="hs-identifier hs-type">ErrMsg</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">err_msg :: ErrMsg -&gt; Doc
</span><a href="Distribution.Backpack.UnifyM.html#err_msg"><span class="hs-identifier hs-var">err_msg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621679722076"><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679722076"><span class="hs-identifier hs-var">msg</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">err_ctx :: ErrMsg -&gt; [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#err_ctx"><span class="hs-identifier hs-var">err_ctx</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621679722075"><span class="annot"><span class="annottext">[Doc]
</span><a href="#local-6989586621679722075"><span class="hs-identifier hs-var">ctx</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-87"></span><span>    </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679722076"><span class="hs-identifier hs-var">msg</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[Doc] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">[Doc]
</span><a href="#local-6989586621679722075"><span class="hs-identifier hs-var">ctx</span></a></span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span class="hs-comment">-- | The unification monad, this monad encapsulates imperative</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- unification.</span><span>
</span><span id="line-91"></span><span class="hs-keyword">newtype</span><span> </span><span id="UnifyM"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span></span><span> </span><span id="local-6989586621679722389"><span class="annot"><a href="#local-6989586621679722389"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679722388"><span class="annot"><a href="#local-6989586621679722388"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="UnifyM"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="unUnifyM"><span class="annot"><span class="annottext">forall s a. UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
</span><a href="Distribution.Backpack.UnifyM.html#unUnifyM"><span class="hs-identifier hs-var hs-var">unUnifyM</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifEnv"><span class="hs-identifier hs-type">UnifEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722389"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722389"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722388"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-comment">-- | Run a computation in the unification monad.</span><span>
</span><span id="line-94"></span><span id="local-6989586621679722379"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#runUnifyM"><span class="hs-identifier hs-type">runUnifyM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Verbosity.html#Verbosity"><span class="hs-identifier hs-type">Verbosity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.ComponentId.html#ComponentId"><span class="hs-identifier hs-type">ComponentId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.FullUnitId.html#FullDb"><span class="hs-identifier hs-type">FullDb</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679722380"><span class="annot"><a href="#local-6989586621679722380"><span class="hs-identifier hs-type">s</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722380"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722379"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><a href="#local-6989586621679722379"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-95"></span><span id="runUnifyM"><span class="annot"><span class="annottext">runUnifyM :: forall a.
Verbosity
-&gt; ComponentId
-&gt; FullDb
-&gt; (forall s. UnifyM s a)
-&gt; Either [Doc] a
</span><a href="Distribution.Backpack.UnifyM.html#runUnifyM"><span class="hs-identifier hs-var hs-var">runUnifyM</span></a></span></span><span> </span><span id="local-6989586621679722070"><span class="annot"><span class="annottext">Verbosity
</span><a href="#local-6989586621679722070"><span class="hs-identifier hs-var">verbosity</span></a></span></span><span> </span><span id="local-6989586621679722069"><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679722069"><span class="hs-identifier hs-var">self_cid</span></a></span></span><span> </span><span id="local-6989586621679722068"><span class="annot"><span class="annottext">FullDb
</span><a href="#local-6989586621679722068"><span class="hs-identifier hs-var">db</span></a></span></span><span> </span><span id="local-6989586621679722067"><span class="annot"><span class="annottext">forall s. UnifyM s a
</span><a href="#local-6989586621679722067"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-96"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s (Either [Doc] a)) -&gt; Either [Doc] a
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="annot"><span class="annottext">((forall s. ST s (Either [Doc] a)) -&gt; Either [Doc] a)
-&gt; (forall s. ST s (Either [Doc] a)) -&gt; Either [Doc] a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679722054"><span class="annot"><span class="annottext">STRef s Int
</span><a href="#local-6989586621679722054"><span class="hs-identifier hs-var">i</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s (STRef s Int)
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-97"></span><span>                 </span><span id="local-6989586621679722052"><span class="annot"><span class="annottext">STRef s (Map ModuleName (ModuleU s))
</span><a href="#local-6989586621679722052"><span class="hs-identifier hs-var">hmap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
-&gt; ST s (STRef s (Map ModuleName (ModuleU s)))
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
forall k a. Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#empty"><span class="hs-identifier hs-var">Map.empty</span></a></span><span>
</span><span id="line-98"></span><span>                 </span><span id="local-6989586621679722050"><span class="annot"><span class="annottext">STRef s [ErrMsg]
</span><a href="#local-6989586621679722050"><span class="hs-identifier hs-var">errs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[ErrMsg] -&gt; ST s (STRef s [ErrMsg])
forall a s. a -&gt; ST s (STRef s a)
</span><a href="../../base/src/GHC.STRef.html#newSTRef"><span class="hs-identifier hs-var">newSTRef</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-99"></span><span>                 </span><span id="local-6989586621679722049"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679722049"><span class="hs-identifier hs-var">mb_r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
forall s a. UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
</span><a href="Distribution.Backpack.UnifyM.html#unUnifyM"><span class="hs-identifier hs-var hs-var">unUnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyM s a
forall s. UnifyM s a
</span><a href="#local-6989586621679722067"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv :: forall s.
UnifRef s Int
-&gt; UnifRef s (Map ModuleName (ModuleU s))
-&gt; ComponentId
-&gt; Verbosity
-&gt; [Doc]
-&gt; FullDb
-&gt; UnifRef s [ErrMsg]
-&gt; UnifEnv s
</span><a href="Distribution.Backpack.UnifyM.html#UnifEnv"><span class="hs-identifier hs-type">UnifEnv</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-100"></span><span>                            </span><span class="annot"><span class="annottext">unify_uniq :: STRef s Int
</span><a href="Distribution.Backpack.UnifyM.html#unify_uniq"><span class="hs-identifier hs-var">unify_uniq</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s Int
</span><a href="#local-6989586621679722054"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-101"></span><span>                            </span><span class="annot"><span class="annottext">unify_reqs :: STRef s (Map ModuleName (ModuleU s))
</span><a href="Distribution.Backpack.UnifyM.html#unify_reqs"><span class="hs-identifier hs-var">unify_reqs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s (Map ModuleName (ModuleU s))
</span><a href="#local-6989586621679722052"><span class="hs-identifier hs-var">hmap</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-102"></span><span>                            </span><span class="annot"><span class="annottext">unify_self_cid :: ComponentId
</span><a href="Distribution.Backpack.UnifyM.html#unify_self_cid"><span class="hs-identifier hs-var">unify_self_cid</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679722069"><span class="hs-identifier hs-var">self_cid</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-103"></span><span>                            </span><span class="annot"><span class="annottext">unify_verbosity :: Verbosity
</span><a href="Distribution.Backpack.UnifyM.html#unify_verbosity"><span class="hs-identifier hs-var">unify_verbosity</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Verbosity
</span><a href="#local-6989586621679722070"><span class="hs-identifier hs-var">verbosity</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-104"></span><span>                            </span><span class="annot"><span class="annottext">unify_ctx :: [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#unify_ctx"><span class="hs-identifier hs-var">unify_ctx</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span>
</span><span id="line-105"></span><span>                            </span><span class="annot"><span class="annottext">unify_db :: FullDb
</span><a href="Distribution.Backpack.UnifyM.html#unify_db"><span class="hs-identifier hs-var">unify_db</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FullDb
</span><a href="#local-6989586621679722068"><span class="hs-identifier hs-var">db</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-106"></span><span>                            </span><span class="annot"><span class="annottext">unify_errs :: STRef s [ErrMsg]
</span><a href="Distribution.Backpack.UnifyM.html#unify_errs"><span class="hs-identifier hs-var">unify_errs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRef s [ErrMsg]
</span><a href="#local-6989586621679722050"><span class="hs-identifier hs-var">errs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-107"></span><span>                 </span><span id="local-6989586621679722040"><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679722040"><span class="hs-identifier hs-var">final_errs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STRef s [ErrMsg] -&gt; ST s [ErrMsg]
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s [ErrMsg]
</span><a href="#local-6989586621679722050"><span class="hs-identifier hs-var">errs</span></a></span><span>
</span><span id="line-108"></span><span>                 </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679722049"><span class="hs-identifier hs-var">mb_r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-109"></span><span>                    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679722038"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679722038"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[ErrMsg] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679722040"><span class="hs-identifier hs-var">final_errs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either [Doc] a -&gt; ST s (Either [Doc] a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Either [Doc] a
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679722038"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>                    </span><span class="annot"><span class="annottext">Maybe a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either [Doc] a -&gt; ST s (Either [Doc] a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Doc] -&gt; Either [Doc] a
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ErrMsg -&gt; Doc) -&gt; [ErrMsg] -&gt; [Doc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">ErrMsg -&gt; Doc
</span><a href="Distribution.Backpack.UnifyM.html#renderErrMsg"><span class="hs-identifier hs-var">renderErrMsg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ErrMsg] -&gt; [ErrMsg]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679722040"><span class="hs-identifier hs-var">final_errs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- NB: GHC 7.6 throws a hissy fit if you pattern match on 'm'.</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-keyword">type</span><span> </span><span id="ErrCtx"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrCtx"><span class="hs-identifier hs-var">ErrCtx</span></a></span></span><span> </span><span id="local-6989586621679722034"><span class="annot"><a href="#local-6989586621679722034"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-comment">-- | The unification environment.</span><span>
</span><span id="line-116"></span><span class="hs-keyword">data</span><span> </span><span id="UnifEnv"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifEnv"><span class="hs-identifier hs-var">UnifEnv</span></a></span></span><span> </span><span id="local-6989586621679722361"><span class="annot"><a href="#local-6989586621679722361"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="UnifEnv"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifEnv"><span class="hs-identifier hs-var">UnifEnv</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-117"></span><span>        </span><span class="hs-comment">-- | A supply of unique integers to label 'UnitIdU'</span><span>
</span><span id="line-118"></span><span>        </span><span class="hs-comment">-- cells.  This is used to determine loops in unit</span><span>
</span><span id="line-119"></span><span>        </span><span class="hs-comment">-- identifiers (which can happen with mutual recursion.)</span><span>
</span><span id="line-120"></span><span>        </span><span id="unify_uniq"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; UnifRef s Int
</span><a href="Distribution.Backpack.UnifyM.html#unify_uniq"><span class="hs-identifier hs-var hs-var">unify_uniq</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifRef"><span class="hs-identifier hs-type">UnifRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722361"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdUnique"><span class="hs-identifier hs-type">UnitIdUnique</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-121"></span><span>        </span><span class="hs-comment">-- | The set of requirements in scope.  When</span><span>
</span><span id="line-122"></span><span>        </span><span class="hs-comment">-- a provision is brought into scope, we unify with</span><span>
</span><span id="line-123"></span><span>        </span><span class="hs-comment">-- the requirement at the same module name to fill it.</span><span>
</span><span id="line-124"></span><span>        </span><span class="hs-comment">-- This mapping grows monotonically.</span><span>
</span><span id="line-125"></span><span>        </span><span id="unify_reqs"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; UnifRef s (Map ModuleName (ModuleU s))
</span><a href="Distribution.Backpack.UnifyM.html#unify_reqs"><span class="hs-identifier hs-var hs-var">unify_reqs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifRef"><span class="hs-identifier hs-type">UnifRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722361"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722361"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-126"></span><span>        </span><span class="hs-comment">-- | Component id of the unit we're linking.  We use this</span><span>
</span><span id="line-127"></span><span>        </span><span class="hs-comment">-- to detect if we fill a requirement with a local module,</span><span>
</span><span id="line-128"></span><span>        </span><span class="hs-comment">-- which in principle should be OK but is not currently</span><span>
</span><span id="line-129"></span><span>        </span><span class="hs-comment">-- supported by GHC.</span><span>
</span><span id="line-130"></span><span>        </span><span id="unify_self_cid"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; ComponentId
</span><a href="Distribution.Backpack.UnifyM.html#unify_self_cid"><span class="hs-identifier hs-var hs-var">unify_self_cid</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.ComponentId.html#ComponentId"><span class="hs-identifier hs-type">ComponentId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-131"></span><span>        </span><span class="hs-comment">-- | How verbose the error message should be</span><span>
</span><span id="line-132"></span><span>        </span><span id="unify_verbosity"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; Verbosity
</span><a href="Distribution.Backpack.UnifyM.html#unify_verbosity"><span class="hs-identifier hs-var hs-var">unify_verbosity</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Verbosity.html#Verbosity"><span class="hs-identifier hs-type">Verbosity</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-133"></span><span>        </span><span class="hs-comment">-- | The error reporting context</span><span>
</span><span id="line-134"></span><span>        </span><span id="unify_ctx"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#unify_ctx"><span class="hs-identifier hs-var hs-var">unify_ctx</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrCtx"><span class="hs-identifier hs-type">ErrCtx</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722361"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>
</span><span id="line-135"></span><span>        </span><span class="hs-comment">-- | The package index for expanding unit identifiers</span><span>
</span><span id="line-136"></span><span>        </span><span id="unify_db"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; FullDb
</span><a href="Distribution.Backpack.UnifyM.html#unify_db"><span class="hs-identifier hs-var hs-var">unify_db</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.FullUnitId.html#FullDb"><span class="hs-identifier hs-type">FullDb</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-137"></span><span>        </span><span class="hs-comment">-- | Accumulated errors</span><span>
</span><span id="line-138"></span><span>        </span><span id="unify_errs"><span class="annot"><span class="annottext">forall s. UnifEnv s -&gt; UnifRef s [ErrMsg]
</span><a href="Distribution.Backpack.UnifyM.html#unify_errs"><span class="hs-identifier hs-var hs-var">unify_errs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifRef"><span class="hs-identifier hs-type">UnifRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722361"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrMsg"><span class="hs-identifier hs-type">ErrMsg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-139"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span id="local-6989586621679722336"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679722030"><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722336"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-142"></span><span>    </span><span id="local-6989586621679722022"><span class="annot"><span class="annottext">fmap :: forall a b. (a -&gt; b) -&gt; UnifyM s a -&gt; UnifyM s b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var hs-var hs-var hs-var">fmap</span></a></span></span><span> </span><span id="local-6989586621679722021"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679722021"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span id="local-6989586621679722020"><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe a)
</span><a href="#local-6989586621679722020"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ST s (Maybe a) -&gt; ST s (Maybe b))
-&gt; (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifEnv s -&gt; ST s (Maybe b)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Maybe a -&gt; Maybe b) -&gt; ST s (Maybe a) -&gt; ST s (Maybe b)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; Maybe a -&gt; Maybe b
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679722021"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe a)
</span><a href="#local-6989586621679722020"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span id="local-6989586621679722320"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679722010"><span id="local-6989586621679722012"><span id="local-6989586621679722014"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722320"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-145"></span><span>    </span><span id="local-6989586621679722002"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; UnifyM s a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a)
-&gt; (a -&gt; UnifEnv s -&gt; ST s (Maybe a)) -&gt; a -&gt; UnifyM s a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ST s (Maybe a) -&gt; UnifEnv s -&gt; ST s (Maybe a)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (Maybe a) -&gt; UnifEnv s -&gt; ST s (Maybe a))
-&gt; (a -&gt; ST s (Maybe a)) -&gt; a -&gt; UnifEnv s -&gt; ST s (Maybe a)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; ST s (Maybe a)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe a -&gt; ST s (Maybe a))
-&gt; (a -&gt; Maybe a) -&gt; a -&gt; ST s (Maybe a)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span>
</span><span id="line-146"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span id="local-6989586621679721995"><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe (a -&gt; b))
</span><a href="#local-6989586621679721995"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679721994"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. UnifyM s (a -&gt; b) -&gt; UnifyM s a -&gt; UnifyM s b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;*&gt;</span></a></span></span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span id="local-6989586621679721993"><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe a)
</span><a href="#local-6989586621679721993"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b)
-&gt; (UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679721992"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721992"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-147"></span><span>        </span><span id="local-6989586621679721991"><span class="annot"><span class="annottext">Maybe (a -&gt; b)
</span><a href="#local-6989586621679721991"><span class="hs-identifier hs-var">f'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe (a -&gt; b))
</span><a href="#local-6989586621679721995"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721992"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-148"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (a -&gt; b)
</span><a href="#local-6989586621679721991"><span class="hs-identifier hs-var">f'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-149"></span><span>          </span><span class="annot"><span class="annottext">Maybe (a -&gt; b)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; ST s (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-150"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721990"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679721990"><span class="hs-identifier hs-var">f''</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-151"></span><span>              </span><span id="local-6989586621679721989"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679721989"><span class="hs-identifier hs-var">x'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe a)
</span><a href="#local-6989586621679721993"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721992"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-152"></span><span>              </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679721989"><span class="hs-identifier hs-var">x'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-153"></span><span>                  </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; ST s (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-154"></span><span>                  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721988"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679721988"><span class="hs-identifier hs-var">x''</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; ST s (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b -&gt; Maybe b
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679721990"><span class="hs-identifier hs-var">f''</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679721988"><span class="hs-identifier hs-var">x''</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span id="local-6989586621679722307"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679721983"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722307"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-157"></span><span>    </span><span id="local-6989586621679721979"><span class="annot"><span class="annottext">return :: forall a. a -&gt; UnifyM s a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var hs-var hs-var hs-var">return</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyM s a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span>
</span><span id="line-158"></span><span>    </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span id="local-6989586621679721976"><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe a)
</span><a href="#local-6989586621679721976"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679721975"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. UnifyM s a -&gt; (a -&gt; UnifyM s b) -&gt; UnifyM s b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621679721974"><span class="annot"><span class="annottext">a -&gt; UnifyM s b
</span><a href="#local-6989586621679721974"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b)
-&gt; (UnifEnv s -&gt; ST s (Maybe b)) -&gt; UnifyM s b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679721973"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721973"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-159"></span><span>        </span><span id="local-6989586621679721972"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679721972"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; ST s (Maybe a)
</span><a href="#local-6989586621679721976"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721973"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-160"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679721972"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-161"></span><span>            </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; ST s (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-162"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721971"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679721971"><span class="hs-identifier hs-var">x'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyM s b -&gt; UnifEnv s -&gt; ST s (Maybe b)
forall s a. UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
</span><a href="Distribution.Backpack.UnifyM.html#unUnifyM"><span class="hs-identifier hs-var hs-var">unUnifyM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; UnifyM s b
</span><a href="#local-6989586621679721974"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679721971"><span class="hs-identifier hs-var">x'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721973"><span class="hs-identifier hs-var">r</span></a></span></span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span class="hs-comment">-- | Lift a computation from 'ST' monad to 'UnifyM' monad.</span><span>
</span><span id="line-165"></span><span class="hs-comment">-- Internal use only.</span><span>
</span><span id="line-166"></span><span id="local-6989586621679722302"><span id="local-6989586621679722303"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-type">liftST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722303"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722302"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722303"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722302"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-167"></span><span id="liftST"><span class="annot"><span class="annottext">liftST :: forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var hs-var">liftST</span></a></span></span><span> </span><span id="local-6989586621679721969"><span class="annot"><span class="annottext">ST s a
</span><a href="#local-6989586621679721969"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a)
-&gt; (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">UnifEnv s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a -&gt; Maybe a) -&gt; ST s a -&gt; ST s (Maybe a)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">ST s a
</span><a href="#local-6989586621679721969"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span id="local-6989586621679722299"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier hs-type">addErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722299"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-170"></span><span id="addErr"><span class="annot"><span class="annottext">addErr :: forall s. Doc -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier hs-var hs-var">addErr</span></a></span></span><span> </span><span id="local-6989586621679721967"><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721967"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-171"></span><span>    </span><span id="local-6989586621679721966"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721966"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifyM s (UnifEnv s)
forall s. UnifyM s (UnifEnv s)
</span><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier hs-var">getUnifEnv</span></a></span><span>
</span><span id="line-172"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721965"><span class="annot"><span class="annottext">err :: ErrMsg
</span><a href="#local-6989586621679721965"><span class="hs-identifier hs-var hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ErrMsg :: Doc -&gt; [Doc] -&gt; ErrMsg
</span><a href="Distribution.Backpack.UnifyM.html#ErrMsg"><span class="hs-identifier hs-type">ErrMsg</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-173"></span><span>                </span><span class="annot"><span class="annottext">err_msg :: Doc
</span><a href="Distribution.Backpack.UnifyM.html#err_msg"><span class="hs-identifier hs-var">err_msg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721967"><span class="hs-identifier hs-var">msg</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-174"></span><span>                </span><span class="annot"><span class="annottext">err_ctx :: [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#err_ctx"><span class="hs-identifier hs-var">err_ctx</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; [Doc]
forall s. UnifEnv s -&gt; [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#unify_ctx"><span class="hs-identifier hs-var hs-var">unify_ctx</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721966"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-175"></span><span>              </span><span class="hs-special">}</span><span>
</span><span id="line-176"></span><span>    </span><span class="annot"><span class="annottext">ST s () -&gt; UnifyM s ()
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s () -&gt; UnifyM s ()) -&gt; ST s () -&gt; UnifyM s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s [ErrMsg] -&gt; ([ErrMsg] -&gt; [ErrMsg]) -&gt; ST s ()
forall s a. STRef s a -&gt; (a -&gt; a) -&gt; ST s ()
</span><a href="../../base/src/Data.STRef.html#modifySTRef"><span class="hs-identifier hs-var">modifySTRef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnifEnv s -&gt; STRef s [ErrMsg]
forall s. UnifEnv s -&gt; UnifRef s [ErrMsg]
</span><a href="Distribution.Backpack.UnifyM.html#unify_errs"><span class="hs-identifier hs-var hs-var">unify_errs</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721966"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679721963"><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679721963"><span class="hs-identifier hs-var">errs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ErrMsg
</span><a href="#local-6989586621679721965"><span class="hs-identifier hs-var">err</span></a></span><span class="annot"><span class="annottext">ErrMsg -&gt; [ErrMsg] -&gt; [ErrMsg]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679721963"><span class="hs-identifier hs-var">errs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span id="local-6989586621679722293"><span id="local-6989586621679722294"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#failWith"><span class="hs-identifier hs-type">failWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722294"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722293"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-179"></span><span id="failWith"><span class="annot"><span class="annottext">failWith :: forall s a. Doc -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#failWith"><span class="hs-identifier hs-var hs-var">failWith</span></a></span></span><span> </span><span id="local-6989586621679721961"><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721961"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-180"></span><span>    </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s ()
forall s. Doc -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721961"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-181"></span><span>    </span><span class="annot"><span class="annottext">UnifyM s a
forall s a. UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#failM"><span class="hs-identifier hs-var">failM</span></a></span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span id="local-6989586621679722289"><span id="local-6989586621679722290"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#failM"><span class="hs-identifier hs-type">failM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722290"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722289"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-184"></span><span id="failM"><span class="annot"><span class="annottext">failM :: forall s a. UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#failM"><span class="hs-identifier hs-var hs-var">failM</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a)
-&gt; (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">UnifEnv s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; ST s (Maybe a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span id="local-6989586621679722286"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#failIfErrs"><span class="hs-identifier hs-type">failIfErrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722286"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-187"></span><span id="failIfErrs"><span class="annot"><span class="annottext">failIfErrs :: forall s. UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#failIfErrs"><span class="hs-identifier hs-var hs-var">failIfErrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-188"></span><span>    </span><span id="local-6989586621679721954"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721954"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifyM s (UnifEnv s)
forall s. UnifyM s (UnifEnv s)
</span><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier hs-var">getUnifEnv</span></a></span><span>
</span><span id="line-189"></span><span>    </span><span id="local-6989586621679721953"><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679721953"><span class="hs-identifier hs-var">errs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s [ErrMsg] -&gt; UnifyM s [ErrMsg]
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s [ErrMsg] -&gt; UnifyM s [ErrMsg])
-&gt; ST s [ErrMsg] -&gt; UnifyM s [ErrMsg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s [ErrMsg] -&gt; ST s [ErrMsg]
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnifEnv s -&gt; STRef s [ErrMsg]
forall s. UnifEnv s -&gt; UnifRef s [ErrMsg]
</span><a href="Distribution.Backpack.UnifyM.html#unify_errs"><span class="hs-identifier hs-var hs-var">unify_errs</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721954"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; UnifyM s () -&gt; UnifyM s ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ErrMsg] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[ErrMsg]
</span><a href="#local-6989586621679721953"><span class="hs-identifier hs-var">errs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UnifyM s ()
forall s a. UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#failM"><span class="hs-identifier hs-var">failM</span></a></span><span>
</span><span id="line-191"></span><span>
</span><span id="line-192"></span><span id="local-6989586621679722282"><span id="local-6989586621679722283"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#tryM"><span class="hs-identifier hs-type">tryM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722283"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722282"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722283"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722282"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-193"></span><span id="tryM"><span class="annot"><span class="annottext">tryM :: forall s a. UnifyM s a -&gt; UnifyM s (Maybe a)
</span><a href="Distribution.Backpack.UnifyM.html#tryM"><span class="hs-identifier hs-var hs-var">tryM</span></a></span></span><span> </span><span id="local-6989586621679721948"><span class="annot"><span class="annottext">UnifyM s a
</span><a href="#local-6989586621679721948"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-194"></span><span>    </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe (Maybe a))) -&gt; UnifyM s (Maybe a)
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679721947"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721947"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-195"></span><span>        </span><span id="local-6989586621679721946"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679721946"><span class="hs-identifier hs-var">mb_r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
forall s a. UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
</span><a href="Distribution.Backpack.UnifyM.html#unUnifyM"><span class="hs-identifier hs-var hs-var">unUnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyM s a
</span><a href="#local-6989586621679721948"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721947"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-196"></span><span>        </span><span class="annot"><span class="annottext">Maybe (Maybe a) -&gt; ST s (Maybe (Maybe a))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe a -&gt; Maybe (Maybe a)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679721946"><span class="hs-identifier hs-var">mb_r</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span>
</span><span id="line-198"></span><span class="hs-comment">{-
otherFail :: ErrMsg -&gt; UnifyM s a
otherFail s = UnifyM $ \_ -&gt; return (Left s)

unifyFail :: ErrMsg -&gt; UnifyM s a
unifyFail err = do
    env &lt;- getUnifEnv
    msg &lt;- case unify_ctx env of
        Nothing -&gt; return (text &quot;Unspecified unification error:&quot; &lt;+&gt; err)
        Just (ctx, mod1, mod2)
            | unify_verbosity env &gt; normal
            -&gt; do mod1' &lt;- convertModuleU mod1
                  mod2' &lt;- convertModuleU mod2
                  let extra = &quot; (was unifying &quot; ++ display mod1'
                                     ++ &quot; and &quot; ++ display mod2' ++ &quot;)&quot;
                  return (ctx ++ err ++ extra)
            | otherwise
            -&gt; return (ctx ++ err ++ &quot; (for more information, pass -v flag)&quot;)
    UnifyM $ \_ -&gt; return (Left msg)
-}</span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span class="hs-comment">-- | A convenient alias for mutable references in the unification monad.</span><span>
</span><span id="line-220"></span><span class="hs-keyword">type</span><span> </span><span id="UnifRef"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifRef"><span class="hs-identifier hs-var">UnifRef</span></a></span></span><span> </span><span id="local-6989586621679721945"><span class="annot"><a href="#local-6989586621679721945"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679721944"><span class="annot"><a href="#local-6989586621679721944"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.STRef.html#STRef"><span class="hs-identifier hs-type">STRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721945"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721944"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="hs-comment">-- | Imperatively read a 'UnifRef'.</span><span>
</span><span id="line-223"></span><span id="local-6989586621679722278"><span id="local-6989586621679722279"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#readUnifRef"><span class="hs-identifier hs-type">readUnifRef</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifRef"><span class="hs-identifier hs-type">UnifRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722279"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722278"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722279"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722278"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-224"></span><span id="readUnifRef"><span class="annot"><span class="annottext">readUnifRef :: forall s a. UnifRef s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#readUnifRef"><span class="hs-identifier hs-var hs-var">readUnifRef</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ST s a -&gt; UnifyM s a
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s a -&gt; UnifyM s a)
-&gt; (STRef s a -&gt; ST s a) -&gt; STRef s a -&gt; UnifyM s a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">STRef s a -&gt; ST s a
forall s a. STRef s a -&gt; ST s a
</span><a href="../../base/src/GHC.STRef.html#readSTRef"><span class="hs-identifier hs-var">readSTRef</span></a></span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span class="hs-comment">-- | Imperatively write a 'UnifRef'.</span><span>
</span><span id="line-227"></span><span id="local-6989586621679722274"><span id="local-6989586621679722275"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#writeUnifRef"><span class="hs-identifier hs-type">writeUnifRef</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifRef"><span class="hs-identifier hs-type">UnifRef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722275"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722274"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679722274"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722275"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-228"></span><span id="writeUnifRef"><span class="annot"><span class="annottext">writeUnifRef :: forall s a. UnifRef s a -&gt; a -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#writeUnifRef"><span class="hs-identifier hs-var hs-var">writeUnifRef</span></a></span></span><span> </span><span id="local-6989586621679721941"><span class="annot"><span class="annottext">UnifRef s a
</span><a href="#local-6989586621679721941"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ST s () -&gt; UnifyM s ()
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s () -&gt; UnifyM s ()) -&gt; (a -&gt; ST s ()) -&gt; a -&gt; UnifyM s ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">UnifRef s a -&gt; a -&gt; ST s ()
forall s a. STRef s a -&gt; a -&gt; ST s ()
</span><a href="../../base/src/GHC.STRef.html#writeSTRef"><span class="hs-identifier hs-var">writeSTRef</span></a></span><span> </span><span class="annot"><span class="annottext">UnifRef s a
</span><a href="#local-6989586621679721941"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span class="hs-comment">-- | Get the current unification environment.</span><span>
</span><span id="line-231"></span><span id="local-6989586621679722297"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier hs-type">getUnifEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722297"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifEnv"><span class="hs-identifier hs-type">UnifEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722297"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-232"></span><span id="getUnifEnv"><span class="annot"><span class="annottext">getUnifEnv :: forall s. UnifyM s (UnifEnv s)
</span><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier hs-var hs-var">getUnifEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe (UnifEnv s))) -&gt; UnifyM s (UnifEnv s)
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe (UnifEnv s))) -&gt; UnifyM s (UnifEnv s))
-&gt; (UnifEnv s -&gt; ST s (Maybe (UnifEnv s))) -&gt; UnifyM s (UnifEnv s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679721936"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721936"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (UnifEnv s) -&gt; ST s (Maybe (UnifEnv s))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnifEnv s -&gt; Maybe (UnifEnv s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721936"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span class="hs-comment">-- | Add a fixed message to the error context.</span><span>
</span><span id="line-235"></span><span id="local-6989586621679722267"><span id="local-6989586621679722268"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#addErrContext"><span class="hs-identifier hs-type">addErrContext</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#Doc"><span class="hs-identifier hs-type">Doc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722268"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722267"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722268"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722267"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-236"></span><span id="addErrContext"><span class="annot"><span class="annottext">addErrContext :: forall s a. Doc -&gt; UnifyM s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#addErrContext"><span class="hs-identifier hs-var hs-var">addErrContext</span></a></span></span><span> </span><span id="local-6989586621679721935"><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721935"><span class="hs-identifier hs-var">ctx</span></a></span></span><span> </span><span id="local-6989586621679721934"><span class="annot"><span class="annottext">UnifyM s a
</span><a href="#local-6989586621679721934"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s a -&gt; UnifyM s a
forall s a. Doc -&gt; UnifyM s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#addErrContextM"><span class="hs-identifier hs-var">addErrContextM</span></a></span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721935"><span class="hs-identifier hs-var">ctx</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyM s a
</span><a href="#local-6989586621679721934"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span class="hs-comment">-- | Add a message to the error context.  It may make monadic queries.</span><span>
</span><span id="line-239"></span><span id="local-6989586621679721932"><span id="local-6989586621679721933"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#addErrContextM"><span class="hs-identifier hs-type">addErrContextM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ErrCtx"><span class="hs-identifier hs-type">ErrCtx</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721933"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721933"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721932"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721933"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721932"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-240"></span><span id="addErrContextM"><span class="annot"><span class="annottext">addErrContextM :: forall s a. Doc -&gt; UnifyM s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#addErrContextM"><span class="hs-identifier hs-var hs-var">addErrContextM</span></a></span></span><span> </span><span id="local-6989586621679721931"><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721931"><span class="hs-identifier hs-var">ctx</span></a></span></span><span> </span><span id="local-6989586621679721930"><span class="annot"><span class="annottext">UnifyM s a
</span><a href="#local-6989586621679721930"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-241"></span><span>    </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall s a. (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-var">UnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">((UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a)
-&gt; (UnifEnv s -&gt; ST s (Maybe a)) -&gt; UnifyM s a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679721929"><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721929"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
forall s a. UnifyM s a -&gt; UnifEnv s -&gt; ST s (Maybe a)
</span><a href="Distribution.Backpack.UnifyM.html#unUnifyM"><span class="hs-identifier hs-var hs-var">unUnifyM</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyM s a
</span><a href="#local-6989586621679721930"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721929"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">unify_ctx :: [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#unify_ctx"><span class="hs-identifier hs-var">unify_ctx</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721931"><span class="hs-identifier hs-var">ctx</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; [Doc] -&gt; [Doc]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; [Doc]
forall s. UnifEnv s -&gt; [Doc]
</span><a href="Distribution.Backpack.UnifyM.html#unify_ctx"><span class="hs-identifier hs-var hs-var">unify_ctx</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s
</span><a href="#local-6989586621679721929"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-242"></span><span>
</span><span id="line-243"></span><span>
</span><span id="line-244"></span><span class="hs-comment">-----------------------------------------------------------------------</span><span>
</span><span id="line-245"></span><span class="hs-comment">-- The &quot;unifiable&quot; variants of the data types</span><span>
</span><span id="line-246"></span><span class="hs-comment">--</span><span>
</span><span id="line-247"></span><span class="hs-comment">-- In order to properly do unification over infinite trees, we</span><span>
</span><span id="line-248"></span><span class="hs-comment">-- need to union find over 'Module's and 'UnitId's.  The pure</span><span>
</span><span id="line-249"></span><span class="hs-comment">-- representation is ill-equipped to do this, so we convert</span><span>
</span><span id="line-250"></span><span class="hs-comment">-- from the pure representation into one which is indirected</span><span>
</span><span id="line-251"></span><span class="hs-comment">-- through union-find.  'ModuleU' handles hole variables;</span><span>
</span><span id="line-252"></span><span class="hs-comment">-- 'UnitIdU' handles mu-binders.</span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span class="hs-comment">-- | Contents of a mutable 'ModuleU' reference.</span><span>
</span><span id="line-255"></span><span class="hs-keyword">data</span><span> </span><span id="ModuleU%27"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU%27"><span class="hs-identifier hs-var">ModuleU'</span></a></span></span><span> </span><span id="local-6989586621679722226"><span class="annot"><a href="#local-6989586621679722226"><span class="hs-identifier hs-type">s</span></a></span></span><span>
</span><span id="line-256"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="ModuleU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-var">ModuleU</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722226"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span>
</span><span id="line-257"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span id="ModuleVarU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleVarU"><span class="hs-identifier hs-var">ModuleVarU</span></a></span></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span>
</span><span id="line-258"></span><span>
</span><span id="line-259"></span><span class="hs-comment">-- | Contents of a mutable 'UnitIdU' reference.</span><span>
</span><span id="line-260"></span><span class="hs-keyword">data</span><span> </span><span id="UnitIdU%27"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU%27"><span class="hs-identifier hs-var">UnitIdU'</span></a></span></span><span> </span><span id="local-6989586621679722242"><span class="annot"><a href="#local-6989586621679722242"><span class="hs-identifier hs-type">s</span></a></span></span><span>
</span><span id="line-261"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="UnitIdU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-var">UnitIdU</span></a></span></span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdUnique"><span class="hs-identifier hs-type">UnitIdUnique</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.ComponentId.html#ComponentId"><span class="hs-identifier hs-type">ComponentId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722242"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span id="UnitIdThunkU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdThunkU"><span class="hs-identifier hs-var">UnitIdThunkU</span></a></span></span><span> </span><span class="annot"><a href="Distribution.Types.UnitId.html#DefUnitId"><span class="hs-identifier hs-type">DefUnitId</span></a></span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-comment">-- | A mutable version of 'Module' which can be imperatively unified.</span><span>
</span><span id="line-265"></span><span class="hs-keyword">type</span><span> </span><span id="ModuleU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-var">ModuleU</span></a></span></span><span> </span><span id="local-6989586621679721924"><span class="annot"><a href="#local-6989586621679721924"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Utils.UnionFind.html#Point"><span class="hs-identifier hs-type">UnionFind.Point</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721924"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU%27"><span class="hs-identifier hs-type">ModuleU'</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721924"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-266"></span><span>
</span><span id="line-267"></span><span class="hs-comment">-- | A mutable version of 'UnitId' which can be imperatively unified.</span><span>
</span><span id="line-268"></span><span class="hs-keyword">type</span><span> </span><span id="UnitIdU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-var">UnitIdU</span></a></span></span><span> </span><span id="local-6989586621679721923"><span class="annot"><a href="#local-6989586621679721923"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Utils.UnionFind.html#Point"><span class="hs-identifier hs-type">UnionFind.Point</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721923"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU%27"><span class="hs-identifier hs-type">UnitIdU'</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721923"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-269"></span><span>
</span><span id="line-270"></span><span class="hs-comment">-- | An integer for uniquely labeling 'UnitIdU' nodes.  We need</span><span>
</span><span id="line-271"></span><span class="hs-comment">-- these labels in order to efficiently serialize 'UnitIdU's into</span><span>
</span><span id="line-272"></span><span class="hs-comment">-- 'UnitId's (we use the label to check if any parent is the</span><span>
</span><span id="line-273"></span><span class="hs-comment">-- node in question, and if so insert a deBruijn index instead.)</span><span>
</span><span id="line-274"></span><span class="hs-comment">-- These labels must be unique across all 'UnitId's/'Module's which</span><span>
</span><span id="line-275"></span><span class="hs-comment">-- participate in unification!</span><span>
</span><span id="line-276"></span><span class="hs-keyword">type</span><span> </span><span id="UnitIdUnique"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdUnique"><span class="hs-identifier hs-var">UnitIdUnique</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-277"></span><span>
</span><span id="line-278"></span><span>
</span><span id="line-279"></span><span class="hs-comment">-----------------------------------------------------------------------</span><span>
</span><span id="line-280"></span><span class="hs-comment">-- Conversion to the unifiable data types</span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span class="hs-comment">-- An environment for tracking the mu-bindings in scope.</span><span>
</span><span id="line-283"></span><span class="hs-comment">-- The invariant for a state @(m, i)@ is that [0..i] are</span><span>
</span><span id="line-284"></span><span class="hs-comment">-- keys of @m@; in fact, the @i-k@th entry is the @k@th</span><span>
</span><span id="line-285"></span><span class="hs-comment">-- de Bruijn index (this saves us from having to shift as</span><span>
</span><span id="line-286"></span><span class="hs-comment">-- we enter mu-binders.)</span><span>
</span><span id="line-287"></span><span class="hs-keyword">type</span><span> </span><span id="MuEnv"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MuEnv"><span class="hs-identifier hs-var">MuEnv</span></a></span></span><span> </span><span id="local-6989586621679721922"><span class="annot"><a href="#local-6989586621679721922"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IntMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721922"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-288"></span><span>
</span><span id="line-289"></span><span id="local-6989586621679722262"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#extendMuEnv"><span class="hs-identifier hs-type">extendMuEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MuEnv"><span class="hs-identifier hs-type">MuEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722262"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722262"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MuEnv"><span class="hs-identifier hs-type">MuEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722262"><span class="hs-identifier hs-type">s</span></a></span></span><span>
</span><span id="line-290"></span><span id="extendMuEnv"><span class="annot"><span class="annottext">extendMuEnv :: forall s. MuEnv s -&gt; UnitIdU s -&gt; MuEnv s
</span><a href="Distribution.Backpack.UnifyM.html#extendMuEnv"><span class="hs-identifier hs-var hs-var">extendMuEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721916"><span class="annot"><span class="annottext">IntMap (UnitIdU s)
</span><a href="#local-6989586621679721916"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721915"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721915"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679721914"><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721914"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-291"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; UnitIdU s -&gt; IntMap (UnitIdU s) -&gt; IntMap (UnitIdU s)
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#insert"><span class="hs-identifier hs-var">IntMap.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721915"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721914"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap (UnitIdU s)
</span><a href="#local-6989586621679721916"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721915"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span>
</span><span id="line-293"></span><span class="hs-comment">{-
lookupMuEnv :: MuEnv s -&gt; Int {- de Bruijn index -} -&gt; UnitIdU s
lookupMuEnv (m, i) k =
    case IntMap.lookup (i - k) m of
        -- Technically a user can trigger this by giving us a
        -- bad 'UnitId', so handle this better.
        Nothing -&gt; error &quot;lookupMuEnv: out of bounds (malformed de Bruijn index)&quot;
        Just v -&gt; v
-}</span><span>
</span><span id="line-302"></span><span>
</span><span id="line-303"></span><span id="local-6989586621679722255"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#emptyMuEnv"><span class="hs-identifier hs-type">emptyMuEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MuEnv"><span class="hs-identifier hs-type">MuEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722255"><span class="hs-identifier hs-type">s</span></a></span></span><span>
</span><span id="line-304"></span><span id="emptyMuEnv"><span class="annot"><span class="annottext">emptyMuEnv :: forall s. MuEnv s
</span><a href="Distribution.Backpack.UnifyM.html#emptyMuEnv"><span class="hs-identifier hs-var hs-var">emptyMuEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IntMap (UnitIdU s)
forall a. IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#empty"><span class="hs-identifier hs-var">IntMap.empty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-305"></span><span>
</span><span id="line-306"></span><span class="hs-comment">-- The workhorse functions.  These share an environment:</span><span>
</span><span id="line-307"></span><span class="hs-comment">--   * @UnifRef s UnitIdUnique@ - the unique label supply for 'UnitIdU' nodes</span><span>
</span><span id="line-308"></span><span class="hs-comment">--   * @UnifRef s (Map ModuleName moduleU)@ - the (lazily initialized)</span><span>
</span><span id="line-309"></span><span class="hs-comment">--     environment containing the implicitly universally quantified</span><span>
</span><span id="line-310"></span><span class="hs-comment">--     @hole:A@ binders.</span><span>
</span><span id="line-311"></span><span class="hs-comment">--   * @MuEnv@ - the environment for mu-binders.</span><span>
</span><span id="line-312"></span><span>
</span><span id="line-313"></span><span id="local-6989586621679722252"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitId%27"><span class="hs-identifier hs-type">convertUnitId'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MuEnv"><span class="hs-identifier hs-type">MuEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722252"><span class="hs-identifier hs-type">s</span></a></span><span>
</span><span id="line-314"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenUnitId"><span class="hs-identifier hs-type">OpenUnitId</span></a></span><span>
</span><span id="line-315"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722252"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722252"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-316"></span><span class="hs-comment">-- TODO: this could be more lazy if we know there are no internal</span><span>
</span><span id="line-317"></span><span class="hs-comment">-- references</span><span>
</span><span id="line-318"></span><span id="convertUnitId%27"><span class="annot"><span class="annottext">convertUnitId' :: forall s. MuEnv s -&gt; OpenUnitId -&gt; UnifyM s (UnitIdU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitId%27"><span class="hs-identifier hs-var hs-var">convertUnitId'</span></a></span></span><span> </span><span class="annot"><span class="annottext">MuEnv s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#DefiniteUnitId"><span class="hs-identifier hs-type">DefiniteUnitId</span></a></span><span> </span><span id="local-6989586621679721889"><span class="annot"><span class="annottext">DefUnitId
</span><a href="#local-6989586621679721889"><span class="hs-identifier hs-var">uid</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-319"></span><span>    </span><span class="annot"><span class="annottext">ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s))
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s)))
-&gt; ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU' s -&gt; ST s (Point s (UnitIdU' s))
forall a s. a -&gt; ST s (Point s a)
</span><a href="Distribution.Utils.UnionFind.html#fresh"><span class="hs-identifier hs-var">UnionFind.fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DefUnitId -&gt; UnitIdU' s
forall s. DefUnitId -&gt; UnitIdU' s
</span><a href="Distribution.Backpack.UnifyM.html#UnitIdThunkU"><span class="hs-identifier hs-var">UnitIdThunkU</span></a></span><span> </span><span class="annot"><span class="annottext">DefUnitId
</span><a href="#local-6989586621679721889"><span class="hs-identifier hs-var">uid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-320"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitId%27"><span class="hs-identifier hs-var">convertUnitId'</span></a></span><span> </span><span id="local-6989586621679721887"><span class="annot"><span class="annottext">MuEnv s
</span><a href="#local-6989586621679721887"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#IndefFullUnitId"><span class="hs-identifier hs-type">IndefFullUnitId</span></a></span><span> </span><span id="local-6989586621679721885"><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679721885"><span class="hs-identifier hs-var">cid</span></a></span></span><span> </span><span id="local-6989586621679721884"><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721884"><span class="hs-identifier hs-var">insts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-321"></span><span>    </span><span id="local-6989586621679721883"><span class="annot"><span class="annottext">UnifRef s Int
</span><a href="#local-6989586621679721883"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; UnifRef s Int)
-&gt; UnifyM s (UnifEnv s) -&gt; UnifyM s (UnifRef s Int)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; UnifRef s Int
forall s. UnifEnv s -&gt; UnifRef s Int
</span><a href="Distribution.Backpack.UnifyM.html#unify_uniq"><span class="hs-identifier hs-var hs-var">unify_uniq</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyM s (UnifEnv s)
forall s. UnifyM s (UnifEnv s)
</span><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier hs-var">getUnifEnv</span></a></span><span>
</span><span id="line-322"></span><span>    </span><span id="local-6989586621679721882"><span class="annot"><span class="annottext">Point s (UnitIdU' s)
</span><a href="#local-6989586621679721882"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s))
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s)))
-&gt; ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU' s -&gt; ST s (Point s (UnitIdU' s))
forall a s. a -&gt; ST s (Point s a)
</span><a href="Distribution.Utils.UnionFind.html#fresh"><span class="hs-identifier hs-var">UnionFind.fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; UnitIdU' s
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;convertUnitId&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- tie the knot later</span><span>
</span><span id="line-323"></span><span>    </span><span id="local-6989586621679721880"><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721880"><span class="hs-identifier hs-var">insts_u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
-&gt; (OpenModule -&gt; UnifyM s (ModuleU s))
-&gt; UnifyM s (Map ModuleName (ModuleU s))
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
t a -&gt; (a -&gt; f b) -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#for"><span class="hs-identifier hs-var">for</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721884"><span class="hs-identifier hs-var">insts</span></a></span><span> </span><span class="annot"><span class="annottext">((OpenModule -&gt; UnifyM s (ModuleU s))
 -&gt; UnifyM s (Map ModuleName (ModuleU s)))
-&gt; (OpenModule -&gt; UnifyM s (ModuleU s))
-&gt; UnifyM s (Map ModuleName (ModuleU s))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MuEnv s -&gt; OpenModule -&gt; UnifyM s (ModuleU s)
forall s. MuEnv s -&gt; OpenModule -&gt; UnifyM s (ModuleU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModule%27"><span class="hs-identifier hs-var">convertModule'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MuEnv s -&gt; Point s (UnitIdU' s) -&gt; MuEnv s
forall s. MuEnv s -&gt; UnitIdU s -&gt; MuEnv s
</span><a href="Distribution.Backpack.UnifyM.html#extendMuEnv"><span class="hs-identifier hs-var">extendMuEnv</span></a></span><span> </span><span class="annot"><span class="annottext">MuEnv s
</span><a href="#local-6989586621679721887"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (UnitIdU' s)
</span><a href="#local-6989586621679721882"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-324"></span><span>    </span><span id="local-6989586621679721877"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721877"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifRef s Int -&gt; UnifyM s Int
forall s a. UnifRef s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#readUnifRef"><span class="hs-identifier hs-var">readUnifRef</span></a></span><span> </span><span class="annot"><span class="annottext">UnifRef s Int
</span><a href="#local-6989586621679721883"><span class="hs-identifier hs-var">fs</span></a></span><span>
</span><span id="line-325"></span><span>    </span><span class="annot"><span class="annottext">UnifRef s Int -&gt; Int -&gt; UnifyM s ()
forall s a. UnifRef s a -&gt; a -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#writeUnifRef"><span class="hs-identifier hs-var">writeUnifRef</span></a></span><span> </span><span class="annot"><span class="annottext">UnifRef s Int
</span><a href="#local-6989586621679721883"><span class="hs-identifier hs-var">fs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721877"><span class="hs-identifier hs-var">u</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-326"></span><span>    </span><span id="local-6989586621679721876"><span class="annot"><span class="annottext">Point s (UnitIdU' s)
</span><a href="#local-6989586621679721876"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s))
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s)))
-&gt; ST s (Point s (UnitIdU' s)) -&gt; UnifyM s (Point s (UnitIdU' s))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU' s -&gt; ST s (Point s (UnitIdU' s))
forall a s. a -&gt; ST s (Point s a)
</span><a href="Distribution.Utils.UnionFind.html#fresh"><span class="hs-identifier hs-var">UnionFind.fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; ComponentId -&gt; Map ModuleName (ModuleU s) -&gt; UnitIdU' s
forall s.
Int -&gt; ComponentId -&gt; Map ModuleName (ModuleU s) -&gt; UnitIdU' s
</span><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-var">UnitIdU</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721877"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679721885"><span class="hs-identifier hs-var">cid</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721880"><span class="hs-identifier hs-var">insts_u</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-327"></span><span>    </span><span class="annot"><span class="annottext">ST s () -&gt; UnifyM s ()
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s () -&gt; UnifyM s ()) -&gt; ST s () -&gt; UnifyM s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (UnitIdU' s) -&gt; Point s (UnitIdU' s) -&gt; ST s ()
forall s a. Point s a -&gt; Point s a -&gt; ST s ()
</span><a href="Distribution.Utils.UnionFind.html#union"><span class="hs-identifier hs-var">UnionFind.union</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (UnitIdU' s)
</span><a href="#local-6989586621679721882"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (UnitIdU' s)
</span><a href="#local-6989586621679721876"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-328"></span><span>    </span><span class="annot"><span class="annottext">Point s (UnitIdU' s) -&gt; UnifyM s (Point s (UnitIdU' s))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Point s (UnitIdU' s)
</span><a href="#local-6989586621679721876"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-329"></span><span class="hs-comment">-- convertUnitId' stk (UnitIdVar i) = return (lookupMuEnv stk i)</span><span>
</span><span id="line-330"></span><span>
</span><span id="line-331"></span><span id="local-6989586621679722233"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModule%27"><span class="hs-identifier hs-type">convertModule'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MuEnv"><span class="hs-identifier hs-type">MuEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722233"><span class="hs-identifier hs-type">s</span></a></span><span>
</span><span id="line-332"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722233"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722233"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-333"></span><span id="convertModule%27"><span class="annot"><span class="annottext">convertModule' :: forall s. MuEnv s -&gt; OpenModule -&gt; UnifyM s (ModuleU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModule%27"><span class="hs-identifier hs-var hs-var">convertModule'</span></a></span></span><span> </span><span id="local-6989586621679721863"><span class="annot"><span class="annottext">MuEnv s
</span><a href="#local-6989586621679721863"><span class="hs-identifier hs-var">_stk</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#OpenModuleVar"><span class="hs-identifier hs-type">OpenModuleVar</span></a></span><span> </span><span id="local-6989586621679721861"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721861"><span class="hs-identifier hs-var">mod_name</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-334"></span><span>    </span><span id="local-6989586621679721860"><span class="annot"><span class="annottext">UnifRef s (Map ModuleName (ModuleU s))
</span><a href="#local-6989586621679721860"><span class="hs-identifier hs-var">hmap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(UnifEnv s -&gt; UnifRef s (Map ModuleName (ModuleU s)))
-&gt; UnifyM s (UnifEnv s)
-&gt; UnifyM s (UnifRef s (Map ModuleName (ModuleU s)))
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">UnifEnv s -&gt; UnifRef s (Map ModuleName (ModuleU s))
forall s. UnifEnv s -&gt; UnifRef s (Map ModuleName (ModuleU s))
</span><a href="Distribution.Backpack.UnifyM.html#unify_reqs"><span class="hs-identifier hs-var hs-var">unify_reqs</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyM s (UnifEnv s)
forall s. UnifyM s (UnifEnv s)
</span><a href="Distribution.Backpack.UnifyM.html#getUnifEnv"><span class="hs-identifier hs-var">getUnifEnv</span></a></span><span>
</span><span id="line-335"></span><span>    </span><span id="local-6989586621679721859"><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721859"><span class="hs-identifier hs-var">hm</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UnifRef s (Map ModuleName (ModuleU s))
-&gt; UnifyM s (Map ModuleName (ModuleU s))
forall s a. UnifRef s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#readUnifRef"><span class="hs-identifier hs-var">readUnifRef</span></a></span><span> </span><span class="annot"><span class="annottext">UnifRef s (Map ModuleName (ModuleU s))
</span><a href="#local-6989586621679721860"><span class="hs-identifier hs-var">hmap</span></a></span><span>
</span><span id="line-336"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; Map ModuleName (ModuleU s) -&gt; Maybe (ModuleU s)
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721861"><span class="hs-identifier hs-var">mod_name</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721859"><span class="hs-identifier hs-var">hm</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-337"></span><span>        </span><span class="annot"><span class="annottext">Maybe (ModuleU s)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679721857"><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721857"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s (ModuleU s) -&gt; UnifyM s (ModuleU s)
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (ModuleU s) -&gt; UnifyM s (ModuleU s))
-&gt; ST s (ModuleU s) -&gt; UnifyM s (ModuleU s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU' s -&gt; ST s (ModuleU s)
forall a s. a -&gt; ST s (Point s a)
</span><a href="Distribution.Utils.UnionFind.html#fresh"><span class="hs-identifier hs-var">UnionFind.fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName -&gt; ModuleU' s
forall s. ModuleName -&gt; ModuleU' s
</span><a href="Distribution.Backpack.UnifyM.html#ModuleVarU"><span class="hs-identifier hs-var">ModuleVarU</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721861"><span class="hs-identifier hs-var">mod_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-338"></span><span>                      </span><span class="annot"><span class="annottext">UnifRef s (Map ModuleName (ModuleU s))
-&gt; Map ModuleName (ModuleU s) -&gt; UnifyM s ()
forall s a. UnifRef s a -&gt; a -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#writeUnifRef"><span class="hs-identifier hs-var">writeUnifRef</span></a></span><span> </span><span class="annot"><span class="annottext">UnifRef s (Map ModuleName (ModuleU s))
</span><a href="#local-6989586621679721860"><span class="hs-identifier hs-var">hmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
-&gt; ModuleU s
-&gt; Map ModuleName (ModuleU s)
-&gt; Map ModuleName (ModuleU s)
forall k a. Ord k =&gt; k -&gt; a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#insert"><span class="hs-identifier hs-var">Map.insert</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721861"><span class="hs-identifier hs-var">mod_name</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721857"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721859"><span class="hs-identifier hs-var">hm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span>                      </span><span class="annot"><span class="annottext">ModuleU s -&gt; UnifyM s (ModuleU s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721857"><span class="hs-identifier hs-var">mod</span></a></span><span>
</span><span id="line-340"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721855"><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721855"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ModuleU s -&gt; UnifyM s (ModuleU s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721855"><span class="hs-identifier hs-var">mod</span></a></span><span>
</span><span id="line-341"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModule%27"><span class="hs-identifier hs-var">convertModule'</span></a></span><span> </span><span id="local-6989586621679721854"><span class="annot"><span class="annottext">MuEnv s
</span><a href="#local-6989586621679721854"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span><span> </span><span id="local-6989586621679721852"><span class="annot"><span class="annottext">OpenUnitId
</span><a href="#local-6989586621679721852"><span class="hs-identifier hs-var">uid</span></a></span></span><span> </span><span id="local-6989586621679721851"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721851"><span class="hs-identifier hs-var">mod_name</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-342"></span><span>    </span><span id="local-6989586621679721850"><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721850"><span class="hs-identifier hs-var">uid_u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MuEnv s -&gt; OpenUnitId -&gt; UnifyM s (UnitIdU s)
forall s. MuEnv s -&gt; OpenUnitId -&gt; UnifyM s (UnitIdU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitId%27"><span class="hs-identifier hs-var">convertUnitId'</span></a></span><span> </span><span class="annot"><span class="annottext">MuEnv s
</span><a href="#local-6989586621679721854"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="annot"><span class="annottext">OpenUnitId
</span><a href="#local-6989586621679721852"><span class="hs-identifier hs-var">uid</span></a></span><span>
</span><span id="line-343"></span><span>    </span><span class="annot"><span class="annottext">ST s (ModuleU s) -&gt; UnifyM s (ModuleU s)
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (ModuleU s) -&gt; UnifyM s (ModuleU s))
-&gt; ST s (ModuleU s) -&gt; UnifyM s (ModuleU s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU' s -&gt; ST s (ModuleU s)
forall a s. a -&gt; ST s (Point s a)
</span><a href="Distribution.Utils.UnionFind.html#fresh"><span class="hs-identifier hs-var">UnionFind.fresh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnitIdU s -&gt; ModuleName -&gt; ModuleU' s
forall s. UnitIdU s -&gt; ModuleName -&gt; ModuleU' s
</span><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-var">ModuleU</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721850"><span class="hs-identifier hs-var">uid_u</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721851"><span class="hs-identifier hs-var">mod_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span id="local-6989586621679722223"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitId"><span class="hs-identifier hs-type">convertUnitId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenUnitId"><span class="hs-identifier hs-type">OpenUnitId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722223"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722223"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-346"></span><span id="convertUnitId"><span class="annot"><span class="annottext">convertUnitId :: forall s. OpenUnitId -&gt; UnifyM s (UnitIdU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitId"><span class="hs-identifier hs-var hs-var">convertUnitId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MuEnv s -&gt; OpenUnitId -&gt; UnifyM s (UnitIdU s)
forall s. MuEnv s -&gt; OpenUnitId -&gt; UnifyM s (UnitIdU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitId%27"><span class="hs-identifier hs-var">convertUnitId'</span></a></span><span> </span><span class="annot"><span class="annottext">MuEnv s
forall s. MuEnv s
</span><a href="Distribution.Backpack.UnifyM.html#emptyMuEnv"><span class="hs-identifier hs-var">emptyMuEnv</span></a></span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span id="local-6989586621679722221"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModule"><span class="hs-identifier hs-type">convertModule</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722221"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722221"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-349"></span><span id="convertModule"><span class="annot"><span class="annottext">convertModule :: forall s. OpenModule -&gt; UnifyM s (ModuleU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModule"><span class="hs-identifier hs-var hs-var">convertModule</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MuEnv s -&gt; OpenModule -&gt; UnifyM s (ModuleU s)
forall s. MuEnv s -&gt; OpenModule -&gt; UnifyM s (ModuleU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModule%27"><span class="hs-identifier hs-var">convertModule'</span></a></span><span> </span><span class="annot"><span class="annottext">MuEnv s
forall s. MuEnv s
</span><a href="Distribution.Backpack.UnifyM.html#emptyMuEnv"><span class="hs-identifier hs-var">emptyMuEnv</span></a></span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span>
</span><span id="line-352"></span><span>
</span><span id="line-353"></span><span class="hs-comment">-----------------------------------------------------------------------</span><span>
</span><span id="line-354"></span><span class="hs-comment">-- Substitutions</span><span>
</span><span id="line-355"></span><span>
</span><span id="line-356"></span><span class="hs-comment">-- | The mutable counterpart of a 'ModuleSubst' (not defined here).</span><span>
</span><span id="line-357"></span><span class="hs-keyword">type</span><span> </span><span id="ModuleSubstU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleSubstU"><span class="hs-identifier hs-var">ModuleSubstU</span></a></span></span><span> </span><span id="local-6989586621679721849"><span class="annot"><a href="#local-6989586621679721849"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721849"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-358"></span><span>
</span><span id="line-359"></span><span class="hs-comment">-- | Conversion of 'ModuleSubst' to 'ModuleSubstU'</span><span>
</span><span id="line-360"></span><span id="local-6989586621679722219"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleSubst"><span class="hs-identifier hs-type">convertModuleSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722219"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722219"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-361"></span><span id="convertModuleSubst"><span class="annot"><span class="annottext">convertModuleSubst :: forall s. OpenModuleSubst -&gt; UnifyM s (Map ModuleName (ModuleU s))
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleSubst"><span class="hs-identifier hs-var hs-var">convertModuleSubst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OpenModule -&gt; UnifyM s (ModuleU s))
-&gt; OpenModuleSubst -&gt; UnifyM s (Map ModuleName (ModuleU s))
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModule -&gt; UnifyM s (ModuleU s)
forall s. OpenModule -&gt; UnifyM s (ModuleU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModule"><span class="hs-identifier hs-var">convertModule</span></a></span><span>
</span><span id="line-362"></span><span>
</span><span id="line-363"></span><span class="hs-comment">-- | Conversion of 'ModuleSubstU' to 'ModuleSubst'</span><span>
</span><span id="line-364"></span><span id="local-6989586621679722213"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleSubstU"><span class="hs-identifier hs-type">convertModuleSubstU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleSubstU"><span class="hs-identifier hs-type">ModuleSubstU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722213"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722213"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModuleSubst"><span class="hs-identifier hs-type">OpenModuleSubst</span></a></span></span><span>
</span><span id="line-365"></span><span id="convertModuleSubstU"><span class="annot"><span class="annottext">convertModuleSubstU :: forall s. ModuleSubstU s -&gt; UnifyM s OpenModuleSubst
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleSubstU"><span class="hs-identifier hs-var hs-var">convertModuleSubstU</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ModuleU s -&gt; UnifyM s OpenModule)
-&gt; Map ModuleName (ModuleU s) -&gt; UnifyM s OpenModuleSubst
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s -&gt; UnifyM s OpenModule
forall s. ModuleU s -&gt; UnifyM s OpenModule
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleU"><span class="hs-identifier hs-var">convertModuleU</span></a></span><span>
</span><span id="line-366"></span><span>
</span><span id="line-367"></span><span class="hs-comment">-----------------------------------------------------------------------</span><span>
</span><span id="line-368"></span><span class="hs-comment">-- Conversion from the unifiable data types</span><span>
</span><span id="line-369"></span><span>
</span><span id="line-370"></span><span class="hs-comment">-- An environment for tracking candidates for adding a mu-binding.</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- The invariant for a state @(m, i)@, is that if we encounter a node</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- labeled @k@ such that @m[k -&gt; v]@, then we can replace this</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- node with the de Bruijn index @i-v@ referring to an enclosing</span><span>
</span><span id="line-374"></span><span class="hs-comment">-- mu-binder; furthermore, @range(m) = [0..i]@.</span><span>
</span><span id="line-375"></span><span class="hs-keyword">type</span><span> </span><span id="MooEnv"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-var">MooEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntMap.Internal.html#IntMap"><span class="hs-identifier hs-type">IntMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-376"></span><span>
</span><span id="line-377"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#emptyMooEnv"><span class="hs-identifier hs-type">emptyMooEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-type">MooEnv</span></a></span><span>
</span><span id="line-378"></span><span id="emptyMooEnv"><span class="annot"><span class="annottext">emptyMooEnv :: MooEnv
</span><a href="Distribution.Backpack.UnifyM.html#emptyMooEnv"><span class="hs-identifier hs-var hs-var">emptyMooEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IntMap Int
forall a. IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#empty"><span class="hs-identifier hs-var">IntMap.empty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#extendMooEnv"><span class="hs-identifier hs-type">extendMooEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-type">MooEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdUnique"><span class="hs-identifier hs-type">UnitIdUnique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-type">MooEnv</span></a></span><span>
</span><span id="line-381"></span><span id="extendMooEnv"><span class="annot"><span class="annottext">extendMooEnv :: MooEnv -&gt; Int -&gt; MooEnv
</span><a href="Distribution.Backpack.UnifyM.html#extendMooEnv"><span class="hs-identifier hs-var hs-var">extendMooEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721841"><span class="annot"><span class="annottext">IntMap Int
</span><a href="#local-6989586621679721841"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721840"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721840"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679721839"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721839"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; IntMap Int -&gt; IntMap Int
forall a. Int -&gt; a -&gt; IntMap a -&gt; IntMap a
</span><a href="../../containers/src/Data.IntMap.Internal.html#insert"><span class="hs-identifier hs-var">IntMap.insert</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721839"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721840"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntMap Int
</span><a href="#local-6989586621679721841"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721840"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#lookupMooEnv"><span class="hs-identifier hs-type">lookupMooEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-type">MooEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdUnique"><span class="hs-identifier hs-type">UnitIdUnique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-384"></span><span id="lookupMooEnv"><span class="annot"><span class="annottext">lookupMooEnv :: MooEnv -&gt; Int -&gt; Maybe Int
</span><a href="Distribution.Backpack.UnifyM.html#lookupMooEnv"><span class="hs-identifier hs-var hs-var">lookupMooEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721837"><span class="annot"><span class="annottext">IntMap Int
</span><a href="#local-6989586621679721837"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721836"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721836"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679721835"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721835"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-385"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntMap Int -&gt; Maybe Int
forall a. Int -&gt; IntMap a -&gt; Maybe a
</span><a href="../../containers/src/Data.IntMap.Internal.html#lookup"><span class="hs-identifier hs-var">IntMap.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721835"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">IntMap Int
</span><a href="#local-6989586621679721837"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-386"></span><span>        </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-387"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721833"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721833"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721836"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721833"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- de Bruijn indexize</span><span>
</span><span id="line-388"></span><span>
</span><span id="line-389"></span><span class="hs-comment">-- The workhorse functions</span><span>
</span><span id="line-390"></span><span>
</span><span id="line-391"></span><span id="local-6989586621679722207"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU%27"><span class="hs-identifier hs-type">convertUnitIdU'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-type">MooEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722207"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722207"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenUnitId"><span class="hs-identifier hs-type">OpenUnitId</span></a></span></span><span>
</span><span id="line-392"></span><span id="convertUnitIdU%27"><span class="annot"><span class="annottext">convertUnitIdU' :: forall s. MooEnv -&gt; UnitIdU s -&gt; UnifyM s OpenUnitId
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU%27"><span class="hs-identifier hs-var hs-var">convertUnitIdU'</span></a></span></span><span> </span><span id="local-6989586621679721825"><span class="annot"><span class="annottext">MooEnv
</span><a href="#local-6989586621679721825"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span id="local-6989586621679721824"><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721824"><span class="hs-identifier hs-var">uid_u</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-393"></span><span>    </span><span id="local-6989586621679721823"><span class="annot"><span class="annottext">UnitIdU' s
</span><a href="#local-6989586621679721823"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s (UnitIdU' s) -&gt; UnifyM s (UnitIdU' s)
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (UnitIdU' s) -&gt; UnifyM s (UnitIdU' s))
-&gt; ST s (UnitIdU' s) -&gt; UnifyM s (UnitIdU' s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU s -&gt; ST s (UnitIdU' s)
forall s a. Point s a -&gt; ST s a
</span><a href="Distribution.Utils.UnionFind.html#find"><span class="hs-identifier hs-var">UnionFind.find</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721824"><span class="hs-identifier hs-var">uid_u</span></a></span><span>
</span><span id="line-394"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UnitIdU' s
</span><a href="#local-6989586621679721823"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-395"></span><span>        </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdThunkU"><span class="hs-identifier hs-type">UnitIdThunkU</span></a></span><span> </span><span id="local-6989586621679721821"><span class="annot"><span class="annottext">DefUnitId
</span><a href="#local-6989586621679721821"><span class="hs-identifier hs-var">uid</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">OpenUnitId -&gt; UnifyM s OpenUnitId
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DefUnitId -&gt; OpenUnitId
</span><a href="Distribution.Backpack.html#DefiniteUnitId"><span class="hs-identifier hs-var">DefiniteUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">DefUnitId
</span><a href="#local-6989586621679721821"><span class="hs-identifier hs-var">uid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span>        </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span id="local-6989586621679721820"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721820"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span id="local-6989586621679721819"><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679721819"><span class="hs-identifier hs-var">cid</span></a></span></span><span> </span><span id="local-6989586621679721818"><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721818"><span class="hs-identifier hs-var">insts_u</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-397"></span><span>            </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MooEnv -&gt; Int -&gt; Maybe Int
</span><a href="Distribution.Backpack.UnifyM.html#lookupMooEnv"><span class="hs-identifier hs-var">lookupMooEnv</span></a></span><span> </span><span class="annot"><span class="annottext">MooEnv
</span><a href="#local-6989586621679721825"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721820"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-398"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721817"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721817"><span class="hs-identifier hs-var">_i</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-399"></span><span>                    </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s OpenUnitId
forall s a. Doc -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#failWith"><span class="hs-identifier hs-var">failWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Unsupported mutually recursive unit identifier&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-400"></span><span>                    </span><span class="hs-comment">-- return (UnitIdVar i)</span><span>
</span><span id="line-401"></span><span>                </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-402"></span><span>                    </span><span id="local-6989586621679721815"><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721815"><span class="hs-identifier hs-var">insts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
-&gt; (ModuleU s -&gt; UnifyM s OpenModule) -&gt; UnifyM s OpenModuleSubst
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
t a -&gt; (a -&gt; f b) -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#for"><span class="hs-identifier hs-var">for</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName (ModuleU s)
</span><a href="#local-6989586621679721818"><span class="hs-identifier hs-var">insts_u</span></a></span><span> </span><span class="annot"><span class="annottext">((ModuleU s -&gt; UnifyM s OpenModule) -&gt; UnifyM s OpenModuleSubst)
-&gt; (ModuleU s -&gt; UnifyM s OpenModule) -&gt; UnifyM s OpenModuleSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MooEnv -&gt; ModuleU s -&gt; UnifyM s OpenModule
forall s. MooEnv -&gt; ModuleU s -&gt; UnifyM s OpenModule
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleU%27"><span class="hs-identifier hs-var">convertModuleU'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MooEnv -&gt; Int -&gt; MooEnv
</span><a href="Distribution.Backpack.UnifyM.html#extendMooEnv"><span class="hs-identifier hs-var">extendMooEnv</span></a></span><span> </span><span class="annot"><span class="annottext">MooEnv
</span><a href="#local-6989586621679721825"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679721820"><span class="hs-identifier hs-var">u</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-403"></span><span>                    </span><span class="annot"><span class="annottext">OpenUnitId -&gt; UnifyM s OpenUnitId
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentId -&gt; OpenModuleSubst -&gt; OpenUnitId
</span><a href="Distribution.Backpack.html#IndefFullUnitId"><span class="hs-identifier hs-var">IndefFullUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679721819"><span class="hs-identifier hs-var">cid</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721815"><span class="hs-identifier hs-var">insts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-404"></span><span>
</span><span id="line-405"></span><span id="local-6989586621679722203"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleU%27"><span class="hs-identifier hs-type">convertModuleU'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#MooEnv"><span class="hs-identifier hs-type">MooEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722203"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722203"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span></span><span>
</span><span id="line-406"></span><span id="convertModuleU%27"><span class="annot"><span class="annottext">convertModuleU' :: forall s. MooEnv -&gt; ModuleU s -&gt; UnifyM s OpenModule
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleU%27"><span class="hs-identifier hs-var hs-var">convertModuleU'</span></a></span></span><span> </span><span id="local-6989586621679721809"><span class="annot"><span class="annottext">MooEnv
</span><a href="#local-6989586621679721809"><span class="hs-identifier hs-var">stk</span></a></span></span><span> </span><span id="local-6989586621679721808"><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721808"><span class="hs-identifier hs-var">mod_u</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-407"></span><span>    </span><span id="local-6989586621679721807"><span class="annot"><span class="annottext">ModuleU' s
</span><a href="#local-6989586621679721807"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s (ModuleU' s) -&gt; UnifyM s (ModuleU' s)
forall s a. ST s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#liftST"><span class="hs-identifier hs-var">liftST</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s (ModuleU' s) -&gt; UnifyM s (ModuleU' s))
-&gt; ST s (ModuleU' s) -&gt; UnifyM s (ModuleU' s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s -&gt; ST s (ModuleU' s)
forall s a. Point s a -&gt; ST s a
</span><a href="Distribution.Utils.UnionFind.html#find"><span class="hs-identifier hs-var">UnionFind.find</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s
</span><a href="#local-6989586621679721808"><span class="hs-identifier hs-var">mod_u</span></a></span><span>
</span><span id="line-408"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModuleU' s
</span><a href="#local-6989586621679721807"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-409"></span><span>        </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleVarU"><span class="hs-identifier hs-type">ModuleVarU</span></a></span><span> </span><span id="local-6989586621679721806"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721806"><span class="hs-identifier hs-var">mod_name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">OpenModule -&gt; UnifyM s OpenModule
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName -&gt; OpenModule
</span><a href="Distribution.Backpack.html#OpenModuleVar"><span class="hs-identifier hs-var">OpenModuleVar</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721806"><span class="hs-identifier hs-var">mod_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-410"></span><span>        </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span id="local-6989586621679721805"><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721805"><span class="hs-identifier hs-var">uid_u</span></a></span></span><span> </span><span id="local-6989586621679721804"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721804"><span class="hs-identifier hs-var">mod_name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-411"></span><span>            </span><span id="local-6989586621679721803"><span class="annot"><span class="annottext">OpenUnitId
</span><a href="#local-6989586621679721803"><span class="hs-identifier hs-var">uid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MooEnv -&gt; UnitIdU s -&gt; UnifyM s OpenUnitId
forall s. MooEnv -&gt; UnitIdU s -&gt; UnifyM s OpenUnitId
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU%27"><span class="hs-identifier hs-var">convertUnitIdU'</span></a></span><span> </span><span class="annot"><span class="annottext">MooEnv
</span><a href="#local-6989586621679721809"><span class="hs-identifier hs-var">stk</span></a></span><span> </span><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721805"><span class="hs-identifier hs-var">uid_u</span></a></span><span>
</span><span id="line-412"></span><span>            </span><span class="annot"><span class="annottext">OpenModule -&gt; UnifyM s OpenModule
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OpenUnitId -&gt; ModuleName -&gt; OpenModule
</span><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-var">OpenModule</span></a></span><span> </span><span class="annot"><span class="annottext">OpenUnitId
</span><a href="#local-6989586621679721803"><span class="hs-identifier hs-var">uid</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721804"><span class="hs-identifier hs-var">mod_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-413"></span><span>
</span><span id="line-414"></span><span class="hs-comment">-- Helper functions</span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span id="local-6989586621679722201"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU"><span class="hs-identifier hs-type">convertUnitIdU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722201"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722201"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenUnitId"><span class="hs-identifier hs-type">OpenUnitId</span></a></span></span><span>
</span><span id="line-417"></span><span id="convertUnitIdU"><span class="annot"><span class="annottext">convertUnitIdU :: forall s. UnitIdU s -&gt; UnifyM s OpenUnitId
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU"><span class="hs-identifier hs-var hs-var">convertUnitIdU</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MooEnv -&gt; UnitIdU s -&gt; UnifyM s OpenUnitId
forall s. MooEnv -&gt; UnitIdU s -&gt; UnifyM s OpenUnitId
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitIdU%27"><span class="hs-identifier hs-var">convertUnitIdU'</span></a></span><span> </span><span class="annot"><span class="annottext">MooEnv
</span><a href="Distribution.Backpack.UnifyM.html#emptyMooEnv"><span class="hs-identifier hs-var">emptyMooEnv</span></a></span><span>
</span><span id="line-418"></span><span>
</span><span id="line-419"></span><span id="local-6989586621679722210"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleU"><span class="hs-identifier hs-type">convertModuleU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722210"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722210"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span></span><span>
</span><span id="line-420"></span><span id="convertModuleU"><span class="annot"><span class="annottext">convertModuleU :: forall s. ModuleU s -&gt; UnifyM s OpenModule
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleU"><span class="hs-identifier hs-var hs-var">convertModuleU</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MooEnv -&gt; ModuleU s -&gt; UnifyM s OpenModule
forall s. MooEnv -&gt; ModuleU s -&gt; UnifyM s OpenModule
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleU%27"><span class="hs-identifier hs-var">convertModuleU'</span></a></span><span> </span><span class="annot"><span class="annottext">MooEnv
</span><a href="Distribution.Backpack.UnifyM.html#emptyMooEnv"><span class="hs-identifier hs-var">emptyMooEnv</span></a></span><span>
</span><span id="line-421"></span><span>
</span><span id="line-422"></span><span class="hs-comment">-- | An empty 'ModuleScopeU'.</span><span>
</span><span id="line-423"></span><span id="local-6989586621679722198"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#emptyModuleScopeU"><span class="hs-identifier hs-type">emptyModuleScopeU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleScopeU"><span class="hs-identifier hs-type">ModuleScopeU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722198"><span class="hs-identifier hs-type">s</span></a></span></span><span>
</span><span id="line-424"></span><span id="emptyModuleScopeU"><span class="annot"><span class="annottext">emptyModuleScopeU :: forall s. ModuleScopeU s
</span><a href="Distribution.Backpack.UnifyM.html#emptyModuleScopeU"><span class="hs-identifier hs-var hs-var">emptyModuleScopeU</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map ModuleName [ModuleWithSourceU s]
forall k a. Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#empty"><span class="hs-identifier hs-var">Map.empty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Map ModuleName [ModuleWithSourceU s]
forall k a. Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#empty"><span class="hs-identifier hs-var">Map.empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-425"></span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="hs-comment">-- | The mutable counterpart of 'ModuleScope'.</span><span>
</span><span id="line-428"></span><span class="hs-keyword">type</span><span> </span><span id="ModuleScopeU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleScopeU"><span class="hs-identifier hs-var">ModuleScopeU</span></a></span></span><span> </span><span id="local-6989586621679721802"><span class="annot"><a href="#local-6989586621679721802"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleProvidesU"><span class="hs-identifier hs-type">ModuleProvidesU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721802"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleRequiresU"><span class="hs-identifier hs-type">ModuleRequiresU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721802"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-429"></span><span class="hs-comment">-- | The mutable counterpart of 'ModuleProvides'</span><span>
</span><span id="line-430"></span><span class="hs-keyword">type</span><span> </span><span id="ModuleProvidesU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleProvidesU"><span class="hs-identifier hs-var">ModuleProvidesU</span></a></span></span><span> </span><span id="local-6989586621679721801"><span class="annot"><a href="#local-6989586621679721801"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleWithSourceU"><span class="hs-identifier hs-type">ModuleWithSourceU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721801"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-431"></span><span class="hs-keyword">type</span><span> </span><span id="ModuleRequiresU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleRequiresU"><span class="hs-identifier hs-var">ModuleRequiresU</span></a></span></span><span> </span><span id="local-6989586621679721800"><span class="annot"><a href="#local-6989586621679721800"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleProvidesU"><span class="hs-identifier hs-type">ModuleProvidesU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721800"><span class="hs-identifier hs-type">s</span></a></span><span>
</span><span id="line-432"></span><span class="hs-keyword">type</span><span> </span><span id="ModuleWithSourceU"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleWithSourceU"><span class="hs-identifier hs-var">ModuleWithSourceU</span></a></span></span><span> </span><span id="local-6989586621679721799"><span class="annot"><a href="#local-6989586621679721799"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html#WithSource"><span class="hs-identifier hs-type">WithSource</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleU"><span class="hs-identifier hs-type">ModuleU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721799"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-433"></span><span>
</span><span id="line-434"></span><span class="hs-comment">-- TODO: Deduplicate this with Distribution.Backpack.MixLink.dispSource</span><span>
</span><span id="line-435"></span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ci_msg"><span class="hs-identifier hs-type">ci_msg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.ComponentInclude.html#ComponentInclude"><span class="hs-identifier hs-type">ComponentInclude</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#OpenUnitId"><span class="hs-identifier hs-type">OpenUnitId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleShape.html#ModuleShape"><span class="hs-identifier hs-type">ModuleShape</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="Distribution.Types.IncludeRenaming.html#IncludeRenaming"><span class="hs-identifier hs-type">IncludeRenaming</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#Doc"><span class="hs-identifier hs-type">Doc</span></a></span><span>
</span><span id="line-436"></span><span id="ci_msg"><span class="annot"><span class="annottext">ci_msg :: ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming -&gt; Doc
</span><a href="Distribution.Backpack.UnifyM.html#ci_msg"><span class="hs-identifier hs-var hs-var">ci_msg</span></a></span></span><span> </span><span id="local-6989586621679721797"><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721797"><span class="hs-identifier hs-var">ci</span></a></span></span><span>
</span><span id="line-437"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming -&gt; Bool
forall id rn. ComponentInclude id rn -&gt; Bool
</span><a href="Distribution.Types.ComponentInclude.html#ci_implicit"><span class="hs-identifier hs-var hs-var">ci_implicit</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721797"><span class="hs-identifier hs-var">ci</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;build-depends:&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721794"><span class="hs-identifier hs-var">pp_pn</span></a></span><span>
</span><span id="line-438"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;mixins:&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="#local-6989586621679721794"><span class="hs-identifier hs-var">pp_pn</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IncludeRenaming -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
-&gt; IncludeRenaming
forall id rn. ComponentInclude id rn -&gt; rn
</span><a href="Distribution.Types.ComponentInclude.html#ci_renaming"><span class="hs-identifier hs-var hs-var">ci_renaming</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721797"><span class="hs-identifier hs-var">ci</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-439"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-440"></span><span>    </span><span id="local-6989586621679721791"><span class="annot"><span class="annottext">pn :: PackageName
</span><a href="#local-6989586621679721791"><span class="hs-identifier hs-var hs-var">pn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIdentifier -&gt; PackageName
</span><a href="Distribution.Types.PackageId.html#pkgName"><span class="hs-identifier hs-var hs-var">pkgName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
-&gt; PackageIdentifier
forall id rn. ComponentInclude id rn -&gt; PackageIdentifier
</span><a href="Distribution.Types.ComponentInclude.html#ci_pkgid"><span class="hs-identifier hs-var">ci_pkgid</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721797"><span class="hs-identifier hs-var">ci</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-441"></span><span>    </span><span id="local-6989586621679721794"><span class="annot"><span class="annottext">pp_pn :: Doc
</span><a href="#local-6989586621679721794"><span class="hs-identifier hs-var hs-var">pp_pn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-442"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
-&gt; ComponentName
forall id rn. ComponentInclude id rn -&gt; ComponentName
</span><a href="Distribution.Types.ComponentInclude.html#ci_cname"><span class="hs-identifier hs-var">ci_cname</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721797"><span class="hs-identifier hs-var">ci</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-443"></span><span>            </span><span class="annot"><a href="Distribution.Types.ComponentName.html#CLibName"><span class="hs-identifier hs-type">CLibName</span></a></span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679721791"><span class="hs-identifier hs-var">pn</span></a></span><span>
</span><span id="line-444"></span><span>            </span><span class="annot"><a href="Distribution.Types.ComponentName.html#CLibName"><span class="hs-identifier hs-type">CLibName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.LibraryName.html#LSubLibName"><span class="hs-identifier hs-type">LSubLibName</span></a></span><span> </span><span id="local-6989586621679721776"><span class="annot"><span class="annottext">UnqualComponentName
</span><a href="#local-6989586621679721776"><span class="hs-identifier hs-var">cn</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679721791"><span class="hs-identifier hs-var">pn</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="Distribution.Compat.Prelude.html#%3C%3C%3E%3E"><span class="hs-operator hs-var">&lt;&lt;&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="Distribution.Compat.Prelude.html#%3C%3C%3E%3E"><span class="hs-operator hs-var">&lt;&lt;&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UnqualComponentName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">UnqualComponentName
</span><a href="#local-6989586621679721776"><span class="hs-identifier hs-var">cn</span></a></span><span>
</span><span id="line-445"></span><span>            </span><span class="hs-comment">-- Shouldn't happen</span><span>
</span><span id="line-446"></span><span>            </span><span id="local-6989586621679721773"><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721773"><span class="hs-identifier hs-var">cn</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679721791"><span class="hs-identifier hs-var">pn</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721773"><span class="hs-identifier hs-var">cn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-447"></span><span>
</span><span id="line-448"></span><span class="hs-comment">-- | Convert a 'ModuleShape' into a 'ModuleScopeU', so we can do</span><span>
</span><span id="line-449"></span><span class="hs-comment">-- unification on it.</span><span>
</span><span id="line-450"></span><span id="local-6989586621679722180"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertInclude"><span class="hs-identifier hs-type">convertInclude</span></a></span><span>
</span><span id="line-451"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.ComponentInclude.html#ComponentInclude"><span class="hs-identifier hs-type">ComponentInclude</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#OpenUnitId"><span class="hs-identifier hs-type">OpenUnitId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleShape.html#ModuleShape"><span class="hs-identifier hs-type">ModuleShape</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="Distribution.Types.IncludeRenaming.html#IncludeRenaming"><span class="hs-identifier hs-type">IncludeRenaming</span></a></span><span>
</span><span id="line-452"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722180"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleScopeU"><span class="hs-identifier hs-type">ModuleScopeU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722180"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-453"></span><span>                 </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.ComponentInclude.html#ComponentInclude"><span class="hs-identifier hs-type">ComponentInclude</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722180"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html#ModuleRenaming"><span class="hs-identifier hs-type">ModuleRenaming</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">{- normal -}</span><span>
</span><span id="line-454"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.ComponentInclude.html#ComponentInclude"><span class="hs-identifier hs-type">ComponentInclude</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnitIdU"><span class="hs-identifier hs-type">UnitIdU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722180"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html#ModuleRenaming"><span class="hs-identifier hs-type">ModuleRenaming</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">{- sig -}</span><span class="hs-special">)</span></span><span>
</span><span id="line-455"></span><span id="convertInclude"><span class="annot"><span class="annottext">convertInclude :: forall s.
ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
-&gt; UnifyM
     s
     (ModuleScopeU s,
      Either
        (ComponentInclude (UnitIdU s) ModuleRenaming)
        (ComponentInclude (UnitIdU s) ModuleRenaming))
</span><a href="Distribution.Backpack.UnifyM.html#convertInclude"><span class="hs-identifier hs-var hs-var">convertInclude</span></a></span></span><span> </span><span id="local-6989586621679721730"><span class="annot"><span class="annottext">ci :: ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721730"><span class="hs-identifier hs-var">ci</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.ComponentInclude.html#ComponentInclude"><span class="hs-identifier hs-type">ComponentInclude</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-456"></span><span>                    </span><span class="annot"><span class="annottext">ci_ann_id :: forall id rn. ComponentInclude id rn -&gt; AnnotatedId id
</span><a href="Distribution.Types.ComponentInclude.html#ci_ann_id"><span class="hs-identifier hs-var">ci_ann_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Types.AnnotatedId.html#AnnotatedId"><span class="hs-identifier hs-type">AnnotatedId</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-457"></span><span>                            </span><span class="annot"><span class="annottext">ann_id :: forall id. AnnotatedId id -&gt; id
</span><a href="Distribution.Types.AnnotatedId.html#ann_id"><span class="hs-identifier hs-var">ann_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721725"><span class="annot"><span class="annottext">OpenUnitId
</span><a href="#local-6989586621679721725"><span class="hs-identifier hs-var">uid</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleShape.html#ModuleShape"><span class="hs-identifier hs-type">ModuleShape</span></a></span><span> </span><span id="local-6989586621679721723"><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721723"><span class="hs-identifier hs-var">provs</span></a></span></span><span> </span><span id="local-6989586621679721722"><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721722"><span class="hs-identifier hs-var">reqs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-458"></span><span>                            </span><span class="annot"><span class="annottext">ann_pid :: forall id. AnnotatedId id -&gt; PackageIdentifier
</span><a href="Distribution.Types.AnnotatedId.html#ann_pid"><span class="hs-identifier hs-var">ann_pid</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621679721720"><span class="annot"><span class="annottext">PackageIdentifier
</span><a href="#local-6989586621679721720"><span class="hs-identifier hs-var">pid</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-459"></span><span>                            </span><span class="annot"><span class="annottext">ann_cname :: forall id. AnnotatedId id -&gt; ComponentName
</span><a href="Distribution.Types.AnnotatedId.html#ann_cname"><span class="hs-identifier hs-var">ann_cname</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621679721718"><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721718"><span class="hs-identifier hs-var">compname</span></a></span></span><span>
</span><span id="line-460"></span><span>                        </span><span class="hs-special">}</span><span class="hs-special">,</span><span>
</span><span id="line-461"></span><span>                    </span><span class="annot"><span class="annottext">ci_renaming :: forall id rn. ComponentInclude id rn -&gt; rn
</span><a href="Distribution.Types.ComponentInclude.html#ci_renaming"><span class="hs-identifier hs-var">ci_renaming</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621679721717"><span class="annot"><span class="annottext">incl :: IncludeRenaming
</span><a href="#local-6989586621679721717"><span class="hs-identifier hs-var">incl</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.IncludeRenaming.html#IncludeRenaming"><span class="hs-identifier hs-type">IncludeRenaming</span></a></span><span> </span><span id="local-6989586621679721715"><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721715"><span class="hs-identifier hs-var">prov_rns</span></a></span></span><span> </span><span id="local-6989586621679721714"><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721714"><span class="hs-identifier hs-var">req_rns</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-462"></span><span>                    </span><span class="annot"><span class="annottext">ci_implicit :: forall id rn. ComponentInclude id rn -&gt; Bool
</span><a href="Distribution.Types.ComponentInclude.html#ci_implicit"><span class="hs-identifier hs-var">ci_implicit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621679721713"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679721713"><span class="hs-identifier hs-var">implicit</span></a></span></span><span>
</span><span id="line-463"></span><span>               </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Doc
-&gt; UnifyM
     s
     ((ModuleProvidesU s, ModuleProvidesU s),
      Either
        (ComponentInclude (UnitIdU s) ModuleRenaming)
        (ComponentInclude (UnitIdU s) ModuleRenaming))
-&gt; UnifyM
     s
     ((ModuleProvidesU s, ModuleProvidesU s),
      Either
        (ComponentInclude (UnitIdU s) ModuleRenaming)
        (ComponentInclude (UnitIdU s) ModuleRenaming))
forall s a. Doc -&gt; UnifyM s a -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#addErrContext"><span class="hs-identifier hs-var">addErrContext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;In&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming -&gt; Doc
</span><a href="Distribution.Backpack.UnifyM.html#ci_msg"><span class="hs-identifier hs-var">ci_msg</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721730"><span class="hs-identifier hs-var">ci</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UnifyM
   s
   ((ModuleProvidesU s, ModuleProvidesU s),
    Either
      (ComponentInclude (UnitIdU s) ModuleRenaming)
      (ComponentInclude (UnitIdU s) ModuleRenaming))
 -&gt; UnifyM
      s
      ((ModuleProvidesU s, ModuleProvidesU s),
       Either
         (ComponentInclude (UnitIdU s) ModuleRenaming)
         (ComponentInclude (UnitIdU s) ModuleRenaming)))
-&gt; UnifyM
     s
     ((ModuleProvidesU s, ModuleProvidesU s),
      Either
        (ComponentInclude (UnitIdU s) ModuleRenaming)
        (ComponentInclude (UnitIdU s) ModuleRenaming))
-&gt; UnifyM
     s
     ((ModuleProvidesU s, ModuleProvidesU s),
      Either
        (ComponentInclude (UnitIdU s) ModuleRenaming)
        (ComponentInclude (UnitIdU s) ModuleRenaming))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-464"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721710"><span class="annot"><span class="annottext">pn :: PackageName
</span><a href="#local-6989586621679721710"><span class="hs-identifier hs-var hs-var">pn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIdentifier -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIdentifier
</span><a href="#local-6989586621679721720"><span class="hs-identifier hs-var">pid</span></a></span><span>
</span><span id="line-465"></span><span>        </span><span id="local-6989586621679721708"><span class="annot"><span class="annottext">the_source :: ModuleSource
</span><a href="#local-6989586621679721708"><span class="hs-identifier hs-var hs-var">the_source</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679721713"><span class="hs-identifier hs-var">implicit</span></a></span><span>
</span><span id="line-466"></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; ComponentName -&gt; ModuleSource
</span><a href="Distribution.Backpack.ModuleScope.html#FromBuildDepends"><span class="hs-identifier hs-var">FromBuildDepends</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679721710"><span class="hs-identifier hs-var">pn</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721718"><span class="hs-identifier hs-var">compname</span></a></span><span>
</span><span id="line-467"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-468"></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; ComponentName -&gt; IncludeRenaming -&gt; ModuleSource
</span><a href="Distribution.Backpack.ModuleScope.html#FromMixins"><span class="hs-identifier hs-var">FromMixins</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679721710"><span class="hs-identifier hs-var">pn</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721718"><span class="hs-identifier hs-var">compname</span></a></span><span> </span><span class="annot"><span class="annottext">IncludeRenaming
</span><a href="#local-6989586621679721717"><span class="hs-identifier hs-var">incl</span></a></span><span>
</span><span id="line-469"></span><span>        </span><span id="local-6989586621679721705"><span class="annot"><span class="annottext">source :: a -&gt; WithSource a
</span><a href="#local-6989586621679721705"><span class="hs-identifier hs-var hs-var">source</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleSource -&gt; a -&gt; WithSource a
forall a. ModuleSource -&gt; a -&gt; WithSource a
</span><a href="Distribution.Backpack.ModuleScope.html#WithSource"><span class="hs-identifier hs-var">WithSource</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleSource
</span><a href="#local-6989586621679721708"><span class="hs-identifier hs-var">the_source</span></a></span><span>
</span><span id="line-470"></span><span>
</span><span id="line-471"></span><span>    </span><span class="hs-comment">-- Suppose our package has two requirements A and B, and</span><span>
</span><span id="line-472"></span><span>    </span><span class="hs-comment">-- we include it with @requires (A as X)@</span><span>
</span><span id="line-473"></span><span>    </span><span class="hs-comment">-- There are three closely related things we compute based</span><span>
</span><span id="line-474"></span><span>    </span><span class="hs-comment">-- off of @reqs@ and @reqs_rns@:</span><span>
</span><span id="line-475"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-476"></span><span>    </span><span class="hs-comment">--      1. The requirement renaming (A -&gt; X)</span><span>
</span><span id="line-477"></span><span>    </span><span class="hs-comment">--      2. The requirement substitution (A -&gt; &lt;X&gt;, B -&gt; &lt;B&gt;)</span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span>    </span><span class="hs-comment">-- Requirement renaming.  This is read straight off the syntax:</span><span>
</span><span id="line-480"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-481"></span><span>    </span><span class="hs-comment">--      [nothing]          ==&gt;  [empty]</span><span>
</span><span id="line-482"></span><span>    </span><span class="hs-comment">--      requires (B as Y)  ==&gt;  B -&gt; Y</span><span>
</span><span id="line-483"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-484"></span><span>    </span><span class="hs-comment">-- Requirement renamings are NOT injective: if two requirements</span><span>
</span><span id="line-485"></span><span>    </span><span class="hs-comment">-- are mapped to the same name, the intent is to merge them</span><span>
</span><span id="line-486"></span><span>    </span><span class="hs-comment">-- together.  But they are *functions*, so @B as X, B as Y@ is</span><span>
</span><span id="line-487"></span><span>    </span><span class="hs-comment">-- illegal.</span><span>
</span><span id="line-488"></span><span>
</span><span id="line-489"></span><span>    </span><span id="local-6989586621679721703"><span class="annot"><span class="annottext">[(ModuleName, ModuleName)]
</span><a href="#local-6989586621679721703"><span class="hs-identifier hs-var">req_rename_list</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-490"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721714"><span class="hs-identifier hs-var">req_rns</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-491"></span><span>        </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="Distribution.Types.ModuleRenaming.html#DefaultRenaming"><span class="hs-identifier hs-var">DefaultRenaming</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)] -&gt; UnifyM s [(ModuleName, ModuleName)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-492"></span><span>        </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html#HidingRenaming"><span class="hs-identifier hs-type">HidingRenaming</span></a></span><span> </span><span class="annot"><span class="annottext">[ModuleName]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-493"></span><span>            </span><span class="hs-comment">-- Not valid here for requires!</span><span>
</span><span id="line-494"></span><span>            </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s ()
forall s. Doc -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">(Doc -&gt; UnifyM s ()) -&gt; Doc -&gt; UnifyM s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Unsupported syntax&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-495"></span><span>                     </span><span class="annot"><span class="annottext">Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;requires hiding (...)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-496"></span><span>            </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)] -&gt; UnifyM s [(ModuleName, ModuleName)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-497"></span><span>        </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html#ModuleRenaming"><span class="hs-identifier hs-type">ModuleRenaming</span></a></span><span> </span><span id="local-6989586621679721698"><span class="annot"><span class="annottext">[(ModuleName, ModuleName)]
</span><a href="#local-6989586621679721698"><span class="hs-identifier hs-var">rns</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)] -&gt; UnifyM s [(ModuleName, ModuleName)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)]
</span><a href="#local-6989586621679721698"><span class="hs-identifier hs-var">rns</span></a></span><span>
</span><span id="line-498"></span><span>
</span><span id="line-499"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="#local-6989586621679721697"><span class="hs-identifier hs-type">req_rename_listmap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-500"></span><span>        </span><span id="local-6989586621679721697"><span class="annot"><span class="annottext">req_rename_listmap :: Map ModuleName [ModuleName]
</span><a href="#local-6989586621679721697"><span class="hs-identifier hs-var hs-var">req_rename_listmap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-501"></span><span>            </span><span class="annot"><span class="annottext">([ModuleName] -&gt; [ModuleName] -&gt; [ModuleName])
-&gt; [(ModuleName, [ModuleName])] -&gt; Map ModuleName [ModuleName]
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#fromListWith"><span class="hs-identifier hs-var">Map.fromListWith</span></a></span><span> </span><span class="annot"><span class="annottext">[ModuleName] -&gt; [ModuleName] -&gt; [ModuleName]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721695"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721694"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721695"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721695"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679721694"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721694"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)]
</span><a href="#local-6989586621679721703"><span class="hs-identifier hs-var">req_rename_list</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-502"></span><span>    </span><span id="local-6989586621679721693"><span class="annot"><span class="annottext">Map ModuleName ModuleName
</span><a href="#local-6989586621679721693"><span class="hs-identifier hs-var">req_rename</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map ModuleName (UnifyM s ModuleName)
-&gt; UnifyM s (Map ModuleName ModuleName)
forall (t :: * -&gt; *) (f :: * -&gt; *) a.
(Traversable t, Applicative f) =&gt;
t (f a) -&gt; f (t a)
</span><a href="../../base/src/Data.Traversable.html#sequenceA"><span class="hs-identifier hs-var">sequenceA</span></a></span><span> </span><span class="annot"><span class="annottext">(Map ModuleName (UnifyM s ModuleName)
 -&gt; UnifyM s (Map ModuleName ModuleName))
-&gt; ((ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
    -&gt; Map ModuleName (UnifyM s ModuleName))
-&gt; (ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
-&gt; UnifyM s (Map ModuleName ModuleName)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">((ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
 -&gt; Map ModuleName [ModuleName]
 -&gt; Map ModuleName (UnifyM s ModuleName))
-&gt; Map ModuleName [ModuleName]
-&gt; (ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
-&gt; Map ModuleName (UnifyM s ModuleName)
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">(ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
-&gt; Map ModuleName [ModuleName]
-&gt; Map ModuleName (UnifyM s ModuleName)
forall k a b. (k -&gt; a -&gt; b) -&gt; Map k a -&gt; Map k b
</span><a href="../../containers/src/Data.Map.Internal.html#mapWithKey"><span class="hs-identifier hs-var">Map.mapWithKey</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName [ModuleName]
</span><a href="#local-6989586621679721697"><span class="hs-identifier hs-var">req_rename_listmap</span></a></span><span> </span><span class="annot"><span class="annottext">((ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
 -&gt; UnifyM s (Map ModuleName ModuleName))
-&gt; (ModuleName -&gt; [ModuleName] -&gt; UnifyM s ModuleName)
-&gt; UnifyM s (Map ModuleName ModuleName)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679721689"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721689"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span id="local-6989586621679721688"><span class="annot"><span class="annottext">[ModuleName]
</span><a href="#local-6989586621679721688"><span class="hs-identifier hs-var">vs0</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-503"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[ModuleName]
</span><a href="#local-6989586621679721688"><span class="hs-identifier hs-var">vs0</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-504"></span><span>        </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; UnifyM s ModuleName
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;req_rename&quot;</span></span><span>
</span><span id="line-505"></span><span>        </span><span class="hs-special">[</span><span id="local-6989586621679721687"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721687"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; UnifyM s ModuleName
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721687"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-506"></span><span>        </span><span id="local-6989586621679721686"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721686"><span class="hs-identifier hs-var">v</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679721685"><span class="annot"><span class="annottext">[ModuleName]
</span><a href="#local-6989586621679721685"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s ()
forall s. Doc -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">(Doc -&gt; UnifyM s ()) -&gt; Doc -&gt; UnifyM s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-507"></span><span>                    </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Conflicting renamings of requirement&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721689"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-508"></span><span>                    </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Renamed to: &quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Doc] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ModuleName -&gt; Doc) -&gt; [ModuleName] -&gt; [Doc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721686"><span class="hs-identifier hs-var">v</span></a></span><span class="annot"><span class="annottext">ModuleName -&gt; [ModuleName] -&gt; [ModuleName]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[ModuleName]
</span><a href="#local-6989586621679721685"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-509"></span><span>                   </span><span class="annot"><span class="annottext">ModuleName -&gt; UnifyM s ModuleName
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721686"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-510"></span><span>
</span><span id="line-511"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721683"><span class="annot"><span class="annottext">req_rename_fn :: ModuleName -&gt; ModuleName
</span><a href="#local-6989586621679721683"><span class="hs-identifier hs-var hs-var">req_rename_fn</span></a></span></span><span> </span><span id="local-6989586621679721682"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721682"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; Map ModuleName ModuleName -&gt; Maybe ModuleName
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721682"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName ModuleName
</span><a href="#local-6989586621679721693"><span class="hs-identifier hs-var">req_rename</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-512"></span><span>                            </span><span class="annot"><span class="annottext">Maybe ModuleName
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721682"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-513"></span><span>                            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721681"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721681"><span class="hs-identifier hs-var">v</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721681"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-514"></span><span>
</span><span id="line-515"></span><span>    </span><span class="hs-comment">-- Requirement substitution.</span><span>
</span><span id="line-516"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-517"></span><span>    </span><span class="hs-comment">--      A -&gt; X      ==&gt;     A -&gt; &lt;X&gt;</span><span>
</span><span id="line-518"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721678"><span class="annot"><span class="annottext">req_subst :: OpenModuleSubst
</span><a href="#local-6989586621679721678"><span class="hs-identifier hs-var hs-var">req_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ModuleName -&gt; OpenModule)
-&gt; Map ModuleName ModuleName -&gt; OpenModuleSubst
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; OpenModule
</span><a href="Distribution.Backpack.html#OpenModuleVar"><span class="hs-identifier hs-var">OpenModuleVar</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName ModuleName
</span><a href="#local-6989586621679721693"><span class="hs-identifier hs-var">req_rename</span></a></span><span>
</span><span id="line-519"></span><span>
</span><span id="line-520"></span><span>    </span><span id="local-6989586621679721677"><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721677"><span class="hs-identifier hs-var">uid_u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OpenUnitId -&gt; UnifyM s (UnitIdU s)
forall s. OpenUnitId -&gt; UnifyM s (UnitIdU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertUnitId"><span class="hs-identifier hs-var">convertUnitId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OpenModuleSubst -&gt; OpenUnitId -&gt; OpenUnitId
forall a. ModSubst a =&gt; OpenModuleSubst -&gt; a -&gt; a
</span><a href="Distribution.Backpack.ModSubst.html#modSubst"><span class="hs-identifier hs-var">modSubst</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721678"><span class="hs-identifier hs-var">req_subst</span></a></span><span> </span><span class="annot"><span class="annottext">OpenUnitId
</span><a href="#local-6989586621679721725"><span class="hs-identifier hs-var">uid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-521"></span><span>
</span><span id="line-522"></span><span>    </span><span class="hs-comment">-- Requirement mapping.  This is just taking the range of the</span><span>
</span><span id="line-523"></span><span>    </span><span class="hs-comment">-- requirement substitution, and making a mapping so that it is</span><span>
</span><span id="line-524"></span><span>    </span><span class="hs-comment">-- convenient to merge things together.  It INCLUDES the implicit</span><span>
</span><span id="line-525"></span><span>    </span><span class="hs-comment">-- mappings.</span><span>
</span><span id="line-526"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-527"></span><span>    </span><span class="hs-comment">--      A -&gt; X      ==&gt;     X -&gt; &lt;X&gt;, B -&gt; &lt;B&gt;</span><span>
</span><span id="line-528"></span><span>    </span><span id="local-6989586621679721675"><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721675"><span class="hs-identifier hs-var">reqs_u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ModuleRequires -&gt; UnifyM s (ModuleProvidesU s)
forall s. ModuleRequires -&gt; UnifyM s (ModuleRequiresU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleRequires"><span class="hs-identifier hs-var">convertModuleRequires</span></a></span><span> </span><span class="annot"><span class="annottext">(ModuleRequires -&gt; UnifyM s (ModuleProvidesU s))
-&gt; ([(ModuleName, [ModuleWithSource])] -&gt; ModuleRequires)
-&gt; [(ModuleName, [ModuleWithSource])]
-&gt; UnifyM s (ModuleProvidesU s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[(ModuleName, [ModuleWithSource])] -&gt; ModuleRequires
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#fromList"><span class="hs-identifier hs-var">Map.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([(ModuleName, [ModuleWithSource])]
 -&gt; UnifyM s (ModuleProvidesU s))
-&gt; [(ModuleName, [ModuleWithSource])]
-&gt; UnifyM s (ModuleProvidesU s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-529"></span><span>                </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721672"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">OpenModule -&gt; ModuleWithSource
forall {a}. a -&gt; WithSource a
</span><a href="#local-6989586621679721705"><span class="hs-identifier hs-var">source</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName -&gt; OpenModule
</span><a href="Distribution.Backpack.html#OpenModuleVar"><span class="hs-identifier hs-var">OpenModuleVar</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721672"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-530"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679721672"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721672"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(ModuleName -&gt; ModuleName) -&gt; [ModuleName] -&gt; [ModuleName]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; ModuleName
</span><a href="#local-6989586621679721683"><span class="hs-identifier hs-var">req_rename_fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set ModuleName -&gt; [ModuleName]
forall a. Set a -&gt; [a]
</span><a href="../../containers/src/Data.Set.Internal.html#toList"><span class="hs-identifier hs-var">Set.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721722"><span class="hs-identifier hs-var">reqs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-531"></span><span>                </span><span class="hs-special">]</span><span>
</span><span id="line-532"></span><span>
</span><span id="line-533"></span><span>    </span><span class="hs-comment">-- Report errors if there were unused renamings</span><span>
</span><span id="line-534"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721669"><span class="annot"><span class="annottext">leftover :: Set ModuleName
</span><a href="#local-6989586621679721669"><span class="hs-identifier hs-var hs-var">leftover</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map ModuleName ModuleName -&gt; Set ModuleName
forall k a. Map k a -&gt; Set k
</span><a href="../../containers/src/Data.Map.Internal.html#keysSet"><span class="hs-identifier hs-var">Map.keysSet</span></a></span><span> </span><span class="annot"><span class="annottext">Map ModuleName ModuleName
</span><a href="#local-6989586621679721693"><span class="hs-identifier hs-var">req_rename</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName -&gt; Set ModuleName -&gt; Set ModuleName
forall a. Ord a =&gt; Set a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#difference"><span class="hs-operator hs-var">`Set.difference`</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721722"><span class="hs-identifier hs-var">reqs</span></a></span><span>
</span><span id="line-535"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; UnifyM s () -&gt; UnifyM s ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set ModuleName -&gt; Bool
forall a. Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#null"><span class="hs-identifier hs-var">Set.null</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721669"><span class="hs-identifier hs-var">leftover</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UnifyM s () -&gt; UnifyM s ()) -&gt; UnifyM s () -&gt; UnifyM s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-536"></span><span>        </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s ()
forall s. Doc -&gt; UnifyM s ()
</span><a href="Distribution.Backpack.UnifyM.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">(Doc -&gt; UnifyM s ()) -&gt; Doc -&gt; UnifyM s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-537"></span><span>            </span><span class="annot"><span class="annottext">Doc -&gt; Int -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;The&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentName -&gt; [Char]
</span><a href="Distribution.Types.ComponentName.html#showComponentName"><span class="hs-identifier hs-var">showComponentName</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721718"><span class="hs-identifier hs-var">compname</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-538"></span><span>                  </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;from package&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIdentifier -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIdentifier
</span><a href="#local-6989586621679721720"><span class="hs-identifier hs-var">pid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-539"></span><span>                  </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;does not require:&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span>
</span><span id="line-540"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Doc] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ModuleName -&gt; Doc) -&gt; [ModuleName] -&gt; [Doc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set ModuleName -&gt; [ModuleName]
forall a. Set a -&gt; [a]
</span><a href="../../containers/src/Data.Set.Internal.html#toList"><span class="hs-identifier hs-var">Set.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721669"><span class="hs-identifier hs-var">leftover</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-541"></span><span>
</span><span id="line-542"></span><span>    </span><span class="hs-comment">-- Provision computation is more complex.</span><span>
</span><span id="line-543"></span><span>    </span><span class="hs-comment">-- For example, if we have:</span><span>
</span><span id="line-544"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-545"></span><span>    </span><span class="hs-comment">--      include p (A as X) requires (B as Y)</span><span>
</span><span id="line-546"></span><span>    </span><span class="hs-comment">--          where A -&gt; q[B=&lt;B&gt;]:A</span><span>
</span><span id="line-547"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-548"></span><span>    </span><span class="hs-comment">-- Then we need:</span><span>
</span><span id="line-549"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-550"></span><span>    </span><span class="hs-comment">--      X -&gt; [(&quot;p&quot;, q[B=&lt;B&gt;]:A)]</span><span>
</span><span id="line-551"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-552"></span><span>    </span><span class="hs-comment">-- There are a bunch of clever ways to present the algorithm</span><span>
</span><span id="line-553"></span><span>    </span><span class="hs-comment">-- but here is the simple one:</span><span>
</span><span id="line-554"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-555"></span><span>    </span><span class="hs-comment">--      1. If we have a default renaming, apply req_subst</span><span>
</span><span id="line-556"></span><span>    </span><span class="hs-comment">--      to provs and use that.</span><span>
</span><span id="line-557"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-558"></span><span>    </span><span class="hs-comment">--      2. Otherwise, build a map by successively looking</span><span>
</span><span id="line-559"></span><span>    </span><span class="hs-comment">--      up the referenced modules in the renaming in provs.</span><span>
</span><span id="line-560"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-561"></span><span>    </span><span class="hs-comment">-- Importantly, overlapping rename targets get accumulated</span><span>
</span><span id="line-562"></span><span>    </span><span class="hs-comment">-- together.  It's not an (immediate) error.</span><span>
</span><span id="line-563"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679721662"><span class="annot"><span class="annottext">[(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721662"><span class="hs-identifier hs-var">pre_prov_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721661"><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721661"><span class="hs-identifier hs-var">prov_rns'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-564"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721715"><span class="hs-identifier hs-var">prov_rns</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-565"></span><span>            </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="Distribution.Types.ModuleRenaming.html#DefaultRenaming"><span class="hs-identifier hs-var">DefaultRenaming</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">([(ModuleName, OpenModule)], ModuleRenaming)
-&gt; UnifyM s ([(ModuleName, OpenModule)], ModuleRenaming)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OpenModuleSubst -&gt; [(ModuleName, OpenModule)]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721723"><span class="hs-identifier hs-var">provs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721715"><span class="hs-identifier hs-var">prov_rns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-566"></span><span>            </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html#HidingRenaming"><span class="hs-identifier hs-type">HidingRenaming</span></a></span><span> </span><span id="local-6989586621679721659"><span class="annot"><span class="annottext">[ModuleName]
</span><a href="#local-6989586621679721659"><span class="hs-identifier hs-var">hides</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-567"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721657"><span class="annot"><span class="annottext">hides_set :: Set ModuleName
</span><a href="#local-6989586621679721657"><span class="hs-identifier hs-var hs-var">hides_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ModuleName] -&gt; Set ModuleName
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">Set.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">[ModuleName]
</span><a href="#local-6989586621679721659"><span class="hs-identifier hs-var">hides</span></a></span><span>
</span><span id="line-568"></span><span>                </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721654"><span class="annot"><span class="annottext">r :: [(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721654"><span class="hs-identifier hs-var hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721653"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">OpenModule
</span><a href="#local-6989586621679721652"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-569"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721653"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721653"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679721652"><span class="annot"><span class="annottext">OpenModule
</span><a href="#local-6989586621679721652"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst -&gt; [(ModuleName, OpenModule)]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721723"><span class="hs-identifier hs-var">provs</span></a></span><span>
</span><span id="line-570"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721653"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; Set ModuleName -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721657"><span class="hs-identifier hs-var">hides_set</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-571"></span><span>                   </span><span class="hs-comment">-- GHC doesn't understand hiding, so expand it out!</span><span>
</span><span id="line-572"></span><span>                   </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">([(ModuleName, OpenModule)], ModuleRenaming)
-&gt; UnifyM s ([(ModuleName, OpenModule)], ModuleRenaming)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721654"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)] -&gt; ModuleRenaming
</span><a href="Distribution.Types.ModuleRenaming.html#ModuleRenaming"><span class="hs-identifier hs-var">ModuleRenaming</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((ModuleName, OpenModule) -&gt; (ModuleName, ModuleName))
-&gt; [(ModuleName, OpenModule)] -&gt; [(ModuleName, ModuleName)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679721650"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721650"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721650"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721650"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="annot"><span class="annottext">(ModuleName -&gt; (ModuleName, ModuleName))
-&gt; ((ModuleName, OpenModule) -&gt; ModuleName)
-&gt; (ModuleName, OpenModule)
-&gt; (ModuleName, ModuleName)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="annot"><span class="annottext">(ModuleName, OpenModule) -&gt; ModuleName
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721654"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-573"></span><span>            </span><span class="annot"><a href="Distribution.Types.ModuleRenaming.html#ModuleRenaming"><span class="hs-identifier hs-type">ModuleRenaming</span></a></span><span> </span><span id="local-6989586621679721649"><span class="annot"><span class="annottext">[(ModuleName, ModuleName)]
</span><a href="#local-6989586621679721649"><span class="hs-identifier hs-var">rns</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-574"></span><span>              </span><span id="local-6989586621679721648"><span class="annot"><span class="annottext">[(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721648"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[UnifyM s (ModuleName, OpenModule)]
-&gt; UnifyM s [(ModuleName, OpenModule)]
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Traversable t, Monad m) =&gt;
t (m a) -&gt; m (t a)
</span><a href="../../base/src/Data.Traversable.html#sequence"><span class="hs-identifier hs-var">sequence</span></a></span><span>
</span><span id="line-575"></span><span>                </span><span class="hs-special">[</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; OpenModuleSubst -&gt; Maybe OpenModule
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721646"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721723"><span class="hs-identifier hs-var">provs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-576"></span><span>                    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679721645"><span class="annot"><span class="annottext">OpenModule
</span><a href="#local-6989586621679721645"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ModuleName, OpenModule) -&gt; UnifyM s (ModuleName, OpenModule)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721644"><span class="hs-identifier hs-var">to</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">OpenModule
</span><a href="#local-6989586621679721645"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-577"></span><span>                    </span><span class="annot"><span class="annottext">Maybe OpenModule
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Doc -&gt; UnifyM s (ModuleName, OpenModule)
forall s a. Doc -&gt; UnifyM s a
</span><a href="Distribution.Backpack.UnifyM.html#failWith"><span class="hs-identifier hs-var">failWith</span></a></span><span> </span><span class="annot"><span class="annottext">(Doc -&gt; UnifyM s (ModuleName, OpenModule))
-&gt; Doc -&gt; UnifyM s (ModuleName, OpenModule)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-578"></span><span>                        </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;Package&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIdentifier -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIdentifier
</span><a href="#local-6989586621679721720"><span class="hs-identifier hs-var">pid</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-579"></span><span>                        </span><span class="annot"><span class="annottext">[Char] -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;does not expose the module&quot;</span></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Doc -&gt; Doc
</span><a href="../../pretty/src/Text.PrettyPrint.HughesPJ.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName -&gt; Doc
forall a. Pretty a =&gt; a -&gt; Doc
</span><a href="Distribution.Pretty.html#pretty"><span class="hs-identifier hs-var">pretty</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721646"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-580"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721646"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721646"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721644"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721644"><span class="hs-identifier hs-var">to</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, ModuleName)]
</span><a href="#local-6989586621679721649"><span class="hs-identifier hs-var">rns</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-581"></span><span>              </span><span class="annot"><span class="annottext">([(ModuleName, OpenModule)], ModuleRenaming)
-&gt; UnifyM s ([(ModuleName, OpenModule)], ModuleRenaming)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721648"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721715"><span class="hs-identifier hs-var">prov_rns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-582"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679721634"><span class="annot"><span class="annottext">prov_scope :: ModuleRequires
</span><a href="#local-6989586621679721634"><span class="hs-identifier hs-var hs-var">prov_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst -&gt; ModuleRequires -&gt; ModuleRequires
forall a. ModSubst a =&gt; OpenModuleSubst -&gt; a -&gt; a
</span><a href="Distribution.Backpack.ModSubst.html#modSubst"><span class="hs-identifier hs-var">modSubst</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721678"><span class="hs-identifier hs-var">req_subst</span></a></span><span>
</span><span id="line-583"></span><span>                   </span><span class="annot"><span class="annottext">(ModuleRequires -&gt; ModuleRequires)
-&gt; ModuleRequires -&gt; ModuleRequires
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">([ModuleWithSource] -&gt; [ModuleWithSource] -&gt; [ModuleWithSource])
-&gt; [(ModuleName, [ModuleWithSource])] -&gt; ModuleRequires
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#fromListWith"><span class="hs-identifier hs-var">Map.fromListWith</span></a></span><span> </span><span class="annot"><span class="annottext">[ModuleWithSource] -&gt; [ModuleWithSource] -&gt; [ModuleWithSource]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span>
</span><span id="line-584"></span><span>                   </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721633"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">OpenModule -&gt; ModuleWithSource
forall {a}. a -&gt; WithSource a
</span><a href="#local-6989586621679721705"><span class="hs-identifier hs-var">source</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModule
</span><a href="#local-6989586621679721632"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-585"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721633"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679721633"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721632"><span class="annot"><span class="annottext">OpenModule
</span><a href="#local-6989586621679721632"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(ModuleName, OpenModule)]
</span><a href="#local-6989586621679721662"><span class="hs-identifier hs-var">pre_prov_scope</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-586"></span><span>
</span><span id="line-587"></span><span>    </span><span id="local-6989586621679721631"><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721631"><span class="hs-identifier hs-var">provs_u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ModuleRequires -&gt; UnifyM s (ModuleProvidesU s)
forall s. ModuleRequires -&gt; UnifyM s (ModuleRequiresU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleProvides"><span class="hs-identifier hs-var">convertModuleProvides</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleRequires
</span><a href="#local-6989586621679721634"><span class="hs-identifier hs-var">prov_scope</span></a></span><span>
</span><span id="line-588"></span><span>
</span><span id="line-589"></span><span>    </span><span class="hs-comment">-- TODO: Assert that provs_u is empty if provs was empty</span><span>
</span><span id="line-590"></span><span>    </span><span class="annot"><span class="annottext">((ModuleProvidesU s, ModuleProvidesU s),
 Either
   (ComponentInclude (UnitIdU s) ModuleRenaming)
   (ComponentInclude (UnitIdU s) ModuleRenaming))
-&gt; UnifyM
     s
     ((ModuleProvidesU s, ModuleProvidesU s),
      Either
        (ComponentInclude (UnitIdU s) ModuleRenaming)
        (ComponentInclude (UnitIdU s) ModuleRenaming))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721631"><span class="hs-identifier hs-var">provs_u</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721675"><span class="hs-identifier hs-var">reqs_u</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-591"></span><span>                </span><span class="hs-comment">-- NB: We test that requirements is not null so that</span><span>
</span><span id="line-592"></span><span>                </span><span class="hs-comment">-- users can create packages with zero module exports</span><span>
</span><span id="line-593"></span><span>                </span><span class="hs-comment">-- that cause some C library to linked in, etc.</span><span>
</span><span id="line-594"></span><span>                </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst -&gt; Bool
forall k a. Map k a -&gt; Bool
</span><a href="../../containers/src/Data.Map.Internal.html#null"><span class="hs-identifier hs-var">Map.null</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModuleSubst
</span><a href="#local-6989586621679721723"><span class="hs-identifier hs-var">provs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Set ModuleName -&gt; Bool
forall a. Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#null"><span class="hs-identifier hs-var">Set.null</span></a></span><span> </span><span class="annot"><span class="annottext">Set ModuleName
</span><a href="#local-6989586621679721722"><span class="hs-identifier hs-var">reqs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-595"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">ComponentInclude (UnitIdU s) ModuleRenaming
-&gt; Either
     (ComponentInclude (UnitIdU s) ModuleRenaming)
     (ComponentInclude (UnitIdU s) ModuleRenaming)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-comment">-- is sig</span><span>
</span><span id="line-596"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">ComponentInclude (UnitIdU s) ModuleRenaming
-&gt; Either
     (ComponentInclude (UnitIdU s) ModuleRenaming)
     (ComponentInclude (UnitIdU s) ModuleRenaming)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentInclude :: forall id rn.
AnnotatedId id -&gt; rn -&gt; Bool -&gt; ComponentInclude id rn
</span><a href="Distribution.Types.ComponentInclude.html#ComponentInclude"><span class="hs-identifier hs-type">ComponentInclude</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-597"></span><span>                                    </span><span class="annot"><span class="annottext">ci_ann_id :: AnnotatedId (UnitIdU s)
</span><a href="Distribution.Types.ComponentInclude.html#ci_ann_id"><span class="hs-identifier hs-var">ci_ann_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnnotatedId :: forall id.
PackageIdentifier -&gt; ComponentName -&gt; id -&gt; AnnotatedId id
</span><a href="Distribution.Types.AnnotatedId.html#AnnotatedId"><span class="hs-identifier hs-type">AnnotatedId</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-598"></span><span>                                            </span><span class="annot"><span class="annottext">ann_id :: UnitIdU s
</span><a href="Distribution.Types.AnnotatedId.html#ann_id"><span class="hs-identifier hs-var">ann_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnitIdU s
</span><a href="#local-6989586621679721677"><span class="hs-identifier hs-var">uid_u</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-599"></span><span>                                            </span><span class="annot"><span class="annottext">ann_pid :: PackageIdentifier
</span><a href="Distribution.Types.AnnotatedId.html#ann_pid"><span class="hs-identifier hs-var">ann_pid</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIdentifier
</span><a href="#local-6989586621679721720"><span class="hs-identifier hs-var">pid</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-600"></span><span>                                            </span><span class="annot"><span class="annottext">ann_cname :: ComponentName
</span><a href="Distribution.Types.AnnotatedId.html#ann_cname"><span class="hs-identifier hs-var">ann_cname</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ComponentName
</span><a href="#local-6989586621679721718"><span class="hs-identifier hs-var">compname</span></a></span><span>
</span><span id="line-601"></span><span>                                        </span><span class="hs-special">}</span><span class="hs-special">,</span><span>
</span><span id="line-602"></span><span>                                    </span><span class="annot"><span class="annottext">ci_renaming :: ModuleRenaming
</span><a href="Distribution.Types.ComponentInclude.html#ci_renaming"><span class="hs-identifier hs-var">ci_renaming</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleRenaming
</span><a href="#local-6989586621679721661"><span class="hs-identifier hs-var">prov_rns'</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-603"></span><span>                                    </span><span class="annot"><span class="annottext">ci_implicit :: Bool
</span><a href="Distribution.Types.ComponentInclude.html#ci_implicit"><span class="hs-identifier hs-var">ci_implicit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming -&gt; Bool
forall id rn. ComponentInclude id rn -&gt; Bool
</span><a href="Distribution.Types.ComponentInclude.html#ci_implicit"><span class="hs-identifier hs-var hs-var">ci_implicit</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming
</span><a href="#local-6989586621679721730"><span class="hs-identifier hs-var">ci</span></a></span><span>
</span><span id="line-604"></span><span>                                    </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-605"></span><span>
</span><span id="line-606"></span><span class="hs-comment">-- | Convert a 'ModuleScopeU' to a 'ModuleScope'.</span><span>
</span><span id="line-607"></span><span id="local-6989586621679722128"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleScopeU"><span class="hs-identifier hs-type">convertModuleScopeU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleScopeU"><span class="hs-identifier hs-type">ModuleScopeU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722128"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722128"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html#ModuleScope"><span class="hs-identifier hs-type">ModuleScope</span></a></span></span><span>
</span><span id="line-608"></span><span id="convertModuleScopeU"><span class="annot"><span class="annottext">convertModuleScopeU :: forall s. ModuleScopeU s -&gt; UnifyM s ModuleScope
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleScopeU"><span class="hs-identifier hs-var hs-var">convertModuleScopeU</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679721625"><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721625"><span class="hs-identifier hs-var">provs_u</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679721624"><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721624"><span class="hs-identifier hs-var">reqs_u</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-609"></span><span>    </span><span id="local-6989586621679721623"><span class="annot"><span class="annottext">ModuleRequires
</span><a href="#local-6989586621679721623"><span class="hs-identifier hs-var">provs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ModuleProvidesU s -&gt; UnifyM s ModuleRequires
forall s. ModuleProvidesU s -&gt; UnifyM s ModuleRequires
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleProvidesU"><span class="hs-identifier hs-var">convertModuleProvidesU</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721625"><span class="hs-identifier hs-var">provs_u</span></a></span><span>
</span><span id="line-610"></span><span>    </span><span id="local-6989586621679721622"><span class="annot"><span class="annottext">ModuleRequires
</span><a href="#local-6989586621679721622"><span class="hs-identifier hs-var">reqs</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ModuleProvidesU s -&gt; UnifyM s ModuleRequires
forall s. ModuleProvidesU s -&gt; UnifyM s ModuleRequires
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleRequiresU"><span class="hs-identifier hs-var">convertModuleRequiresU</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleProvidesU s
</span><a href="#local-6989586621679721624"><span class="hs-identifier hs-var">reqs_u</span></a></span><span>
</span><span id="line-611"></span><span>    </span><span class="hs-comment">-- TODO: Test that the requirements are still free. If they</span><span>
</span><span id="line-612"></span><span>    </span><span class="hs-comment">-- are not, they got unified, and that's dodgy at best.</span><span>
</span><span id="line-613"></span><span>    </span><span class="annot"><span class="annottext">ModuleScope -&gt; UnifyM s ModuleScope
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleRequires -&gt; ModuleRequires -&gt; ModuleScope
</span><a href="Distribution.Backpack.ModuleScope.html#ModuleScope"><span class="hs-identifier hs-var">ModuleScope</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleRequires
</span><a href="#local-6989586621679721623"><span class="hs-identifier hs-var">provs</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleRequires
</span><a href="#local-6989586621679721622"><span class="hs-identifier hs-var">reqs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-614"></span><span>
</span><span id="line-615"></span><span class="hs-comment">-- | Convert a 'ModuleProvides' to a 'ModuleProvidesU'</span><span>
</span><span id="line-616"></span><span id="local-6989586621679721619"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleProvides"><span class="hs-identifier hs-type">convertModuleProvides</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html#ModuleProvides"><span class="hs-identifier hs-type">ModuleProvides</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721619"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleProvidesU"><span class="hs-identifier hs-type">ModuleProvidesU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721619"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-617"></span><span id="convertModuleProvides"><span class="annot"><span class="annottext">convertModuleProvides :: forall s. ModuleRequires -&gt; UnifyM s (ModuleRequiresU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleProvides"><span class="hs-identifier hs-var hs-var">convertModuleProvides</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([ModuleWithSource] -&gt; UnifyM s [WithSource (ModuleU s)])
-&gt; ModuleRequires
-&gt; UnifyM s (Map ModuleName [WithSource (ModuleU s)])
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ModuleWithSource -&gt; UnifyM s (WithSource (ModuleU s)))
-&gt; [ModuleWithSource] -&gt; UnifyM s [WithSource (ModuleU s)]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OpenModule -&gt; UnifyM s (ModuleU s))
-&gt; ModuleWithSource -&gt; UnifyM s (WithSource (ModuleU s))
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">OpenModule -&gt; UnifyM s (ModuleU s)
forall s. OpenModule -&gt; UnifyM s (ModuleU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModule"><span class="hs-identifier hs-var">convertModule</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-618"></span><span>
</span><span id="line-619"></span><span class="hs-comment">-- | Convert a 'ModuleProvidesU' to a 'ModuleProvides'</span><span>
</span><span id="line-620"></span><span id="local-6989586621679722125"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleProvidesU"><span class="hs-identifier hs-type">convertModuleProvidesU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleProvidesU"><span class="hs-identifier hs-type">ModuleProvidesU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722125"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722125"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html#ModuleProvides"><span class="hs-identifier hs-type">ModuleProvides</span></a></span></span><span>
</span><span id="line-621"></span><span id="convertModuleProvidesU"><span class="annot"><span class="annottext">convertModuleProvidesU :: forall s. ModuleProvidesU s -&gt; UnifyM s ModuleRequires
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleProvidesU"><span class="hs-identifier hs-var hs-var">convertModuleProvidesU</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([WithSource (ModuleU s)] -&gt; UnifyM s [ModuleWithSource])
-&gt; Map ModuleName [WithSource (ModuleU s)]
-&gt; UnifyM s ModuleRequires
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(WithSource (ModuleU s) -&gt; UnifyM s ModuleWithSource)
-&gt; [WithSource (ModuleU s)] -&gt; UnifyM s [ModuleWithSource]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ModuleU s -&gt; UnifyM s OpenModule)
-&gt; WithSource (ModuleU s) -&gt; UnifyM s ModuleWithSource
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleU s -&gt; UnifyM s OpenModule
forall s. ModuleU s -&gt; UnifyM s OpenModule
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleU"><span class="hs-identifier hs-var">convertModuleU</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-622"></span><span>
</span><span id="line-623"></span><span id="local-6989586621679722152"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleRequires"><span class="hs-identifier hs-type">convertModuleRequires</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html#ModuleRequires"><span class="hs-identifier hs-type">ModuleRequires</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722152"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleRequiresU"><span class="hs-identifier hs-type">ModuleRequiresU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679722152"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-624"></span><span id="convertModuleRequires"><span class="annot"><span class="annottext">convertModuleRequires :: forall s. ModuleRequires -&gt; UnifyM s (ModuleRequiresU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleRequires"><span class="hs-identifier hs-var hs-var">convertModuleRequires</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleRequires -&gt; UnifyM s (ModuleProvidesU s)
forall s. ModuleRequires -&gt; UnifyM s (ModuleRequiresU s)
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleProvides"><span class="hs-identifier hs-var">convertModuleProvides</span></a></span><span>
</span><span id="line-625"></span><span>
</span><span id="line-626"></span><span id="local-6989586621679721604"><span class="annot"><a href="Distribution.Backpack.UnifyM.html#convertModuleRequiresU"><span class="hs-identifier hs-type">convertModuleRequiresU</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#ModuleRequiresU"><span class="hs-identifier hs-type">ModuleRequiresU</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721604"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Backpack.UnifyM.html#UnifyM"><span class="hs-identifier hs-type">UnifyM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679721604"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.ModuleScope.html#ModuleRequires"><span class="hs-identifier hs-type">ModuleRequires</span></a></span></span><span>
</span><span id="line-627"></span><span id="convertModuleRequiresU"><span class="annot"><span class="annottext">convertModuleRequiresU :: forall s. ModuleProvidesU s -&gt; UnifyM s ModuleRequires
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleRequiresU"><span class="hs-identifier hs-var hs-var">convertModuleRequiresU</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleProvidesU s -&gt; UnifyM s ModuleRequires
forall s. ModuleProvidesU s -&gt; UnifyM s ModuleRequires
</span><a href="Distribution.Backpack.UnifyM.html#convertModuleProvidesU"><span class="hs-identifier hs-var">convertModuleProvidesU</span></a></span><span>
</span><span id="line-628"></span></pre></body></html>